Laravel 5关闭功能替代 [英] Laravel 5 shutdown function alternative

查看:132
本文介绍了Laravel 5关闭功能替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Application :: shutdown()函数已删除,因此我正在寻找替代方法,它将帮助我确定Laravel已完成,在运行结束之前. 可以帮助我的另一件事是Laravel使用的最后一个功能.

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.

注意:我不需要注册回调,我正在构建一个分析工具,该工具需要了解Laravel的运行情况.

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

谢谢.

推荐答案

在Laravel 5中,shutdown()已由

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

这是在 HTTP响应已发送到浏览器之后运行的中间件.

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
    }

}

这篇关于Laravel 5关闭功能替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆