Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 shutdown function alternative

Since Application::shutdown() function has removed, I'm looking for alternative which will assist me determine Laravel has finished, a moment before the end of the running. Another thing which can assist me, is the last function that Laravel use.

Note: I don't need to register a callback, I'm building a profiling tool which need to understand Laravel done its run.

Thanks.

like image 964
Idan Gozlan Avatar asked Jun 14 '26 21:06

Idan Gozlan


1 Answers

In Laravel 5 the shutdown() has been replaced by Terminable Middleware

This is middleware that is run after the HTTP response has already been sent to the browser.

use Illuminate\Contracts\Routing\TerminableMiddleware;

class MyProfiler implements TerminableMiddleware {

    public function handle($request, $next)
    {
        return $next($request);
    }

    public function terminate($request, $response)
    {
        // Do your profiling here
    }

}
like image 88
Laurence Avatar answered Jun 18 '26 00:06

Laurence