PHP Classes
elePHPant
Icontem

Simple MVC Shutdown Manager: Manage PHP script shutdown functions

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2011-05-02 (4 years ago) RSS 2.0 feedNot enough user ratingsTotal: 230 All time: 7,278 This week: 1,338Up
Version License PHP version Categories  
mvc-shutdown-manager 1.0MIT/X Consortium ...5PHP 5, Language
Description Author  

This class can manage multiple PHP script shutdown functions.

It can manage a list of callback functions that should be called when the current PHP script exits.

The class can register a shutdown function with a given execution priority, unregister a function, check if a given function is registered, and execute all shutdown functions according to the associated priority.

Picture of Jonathan Gotti
Name: Jonathan Gotti is available for providing paid consulting. Contact Jonathan Gotti .
Classes: 13 packages by
Country: France France
Age: 39
All time rank: 694 in France France
Week rank: 165 Down7 in France France Down
Innovation award
Innovation award
Nominee: 4x

Details provided by the author  
shutdownManager will assist you managing your shutdown handlers.
The main purpose of this class it to allow you to priorize your shutdown handlers without matter about the order you registered them in your code.
The other benefits versus traditional register_shutdown_function is the possibility to remove a previously registered handlers or even avoid all of them at once.
Here's some example of what you can do.
#- registering a new handler:
$callableCallback = 'myShutdownHandler'; // see php doc of call_user_func for info about valid callable callbacks
$priority = 0; // optional priority of your callback default to 0 higher values means later call
$handlerId = smvcShutdownManager::register($callableCallback,$priority);

#- to check if an handler is registered:
smvcShutdownManager::isRegistered($handlerId);
or 
smvcShutdownManager::isRegistered($callableCallback);

#- get all registered handlers:
$registeredHandlers = smvcShutdownManager::isRegistered();

#- remove handler:
smvcShutdownManager::unregister($handlerId);
or
smvcShutdownManager::unregister($callableCallback);

#- remmoving all handlers at once:
smvcShutdownManager::unregister(null);

#- exit script bypassing registered handlers all at once:
$exitStatut=0; // this value will be passed to exit function so see exit doc for more info on what you can pass here
$bypassCallbacks = true; // setting second parameter to true will simply ignore any previously registered handlers.
smvcShutdownManager::shutdown($exitStatut,$bypassCallbacks);


  Files folder image Files  
File Role Description
Accessible without login Plain text file README Doc. simple documentation
Accessible without login Plain text file shutdownManager.php Class main class source

 Version Control Unique User Downloads Download Rankings  
 0%Total:230All time:7,278
 This week:0This week:1,338Up