出现致命错误:
在 laravel 5 中调用未定义的方法 Illuminate\Foundation\Application::shutdown()
代码示例
App::shutdown(
function () {
// do somthing
}
);
使用 Laravel 5 中删除的 Application::shutdown 方法注册“关闭”回调https://github.com/laravel/framework/commit/62ae860596f17a80954c106ff179288205a74d78 https://github.com/laravel/framework/commit/62ae860596f17a80954c106ff179288205a74d78
作为替代方案,您可以使用
1) 注册关闭函数 http://php.net/manual/en/function.register-shutdown-function.phpPHP 原生函数
2) 使用 laravel 中间件并实现 Illuminate\Contracts\Routing\TerminableMiddleware 接口
你需要工具
public function terminate($request, $response)
TerminableMiddleware 接口的函数。
终止函数将在脚本结束时被调用。
例如 laravel 使用可终止中间件接口在照亮\会话\中间件\StartSession用于在脚本末尾存储会话数据的类
代码示例表单源
public function terminate($request, $response)
{
if ($this->sessionConfigured() && ! $this->usingCookieSessions())
{
$this->manager->driver()->save();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)