問題描述
由于 Application::shutdown() 函數(shù)已被刪除,我正在尋找替代方法來幫助我確定 Laravel 已完成,在運行結(jié)束前一刻.另一件可以幫助我的事情是 Laravel 使用的最后一個函數(shù).
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.
注意:我不需要注冊回調(diào),我正在構(gòu)建一個需要了解 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 響應(yīng)已經(jīng)發(fā)送到瀏覽器之后 運行的中間件.
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
}
}
這篇關(guān)于Laravel 5 關(guān)機功能替代的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!