Laravel 5-未找到Application :: shutdown()函数,是否有替代解决方案? [英] Laravel 5 - Application::shutdown() function not found, is there any alternative solution?
问题描述
出现致命错误:
调用laravel 5中未定义的方法Illuminate \ Foundation \ Application :: shutdown()
Call to undefined method Illuminate\Foundation\Application::shutdown() in laravel 5
代码示例
App::shutdown(
function () {
// do somthing
}
);
推荐答案
使用laravel 5中删除的Application :: shutdown方法注册关闭"回调 https://github.com/laravel/framework/commit/62ae860596f17a80954c106ff179288205a74d78
Register a "shutdown" callbacks with Application::shutdown method removed in laravel 5 https://github.com/laravel/framework/commit/62ae860596f17a80954c106ff179288205a74d78
您也可以使用
1) register_shutdown_function php本机功能
1) register_shutdown_function php native function
2)使用laravel中间件并实现Illuminate \ Contracts \ Routing \ TerminableMiddleware界面
您需要工具
public function terminate($request, $response)
TerminableMiddleware界面的
功能. 终止功能将在脚本结尾处调用.
function for TerminableMiddleware interface. terminate function will be called at the end of the script.
例如laravel使用 Illuminate \ Session \ Middleware \ StartSession 类中的 TerminableMiddleware 接口在脚本末尾存储会话数据
For example laravel use TerminableMiddleware interface in Illuminate\Session\Middleware\StartSession class to store session data at the end of the script
代码示例表单来源
public function terminate($request, $response)
{
if ($this->sessionConfigured() && ! $this->usingCookieSessions())
{
$this->manager->driver()->save();
}
}
这篇关于Laravel 5-未找到Application :: shutdown()函数,是否有替代解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!