Registering a Shutdown Callback

Problem

You want to execute code just before your application finishes.

Solution

Register a Shutdown callback.

App::shutdown(function()
{
    // gets called right before app quits.
});

Discussion

Shutdown callbacks occur after the response has been sent to the user.

They occur during the shutdown process, right before the application exits. Typically they're used to close open services or do logging.

comments powered by Disqus