Skip to content
/ delay Public

Delay some task at the end of script, after sending response to the client

License

Notifications You must be signed in to change notification settings

f2r/delay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Delay

=======

Delay some task at the end of script, after sending response to the client

Usage :

\f2r\FPM\Delay::register(function(){
       file_put_contents('/var/log/trace.log', time() ."\n", FILE_APPEND);
});

Because it's not possible to echo some text after the request disconnection, you can add a PSR3 compatible logger in order to manage exceptions generated by the callback.

\f2r\FPM\Delay::setLogger($logger);

You can send parameter to your callback like this :

\f2r\FPM\Delay::register($callback, [4, true]);

This will perform your callback like this : $callback(4, true);

It's also possible to manage callback priority. If you want to execute a callback before the others, and a callback after, you can do like this:

\f2r\FPM\Delay::register($aCallback);
\f2r\FPM\Delay::register($anotherCallback);
\f2r\FPM\Delay::register($firstCallback, [], -1);
\f2r\FPM\Delay::register($lastCallback, [], 1);

Priority can be a signed integer, and the callbacks will be ordered with this priority.

About

Delay some task at the end of script, after sending response to the client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages