沃梦达 / 编程问答 / php问题 / 正文

Laravel 5 关机功能替代

Laravel 5 shutdown function alternative(Laravel 5 关机功能替代)

本文介绍了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 IlluminateContractsRoutingTerminableMiddleware;

class MyProfiler implements TerminableMiddleware {

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

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

}

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

本文标题为:Laravel 5 关机功能替代

基础教程推荐