获取致命错误:Laravel 5 - Application :: shutdown()函数未找到,是否有任何替代解决方案?
Call to undefined method Illuminate\Foundation\Application::shutdown() in laravel 5
代码示例
App::shutdown(
function() {
// do somthing
}
);
获取致命错误:Laravel 5 - Application :: shutdown()函数未找到,是否有任何替代解决方案?
Call to undefined method Illuminate\Foundation\Application::shutdown() in laravel 5
代码示例
App::shutdown(
function() {
// do somthing
}
);
注册与应用::关机方法的 “关机” 回调在laravel取出5 https://github.com/laravel/framework/commit/62ae860596f17a80954c106ff179288205a74d78
作为替代,您可以使用
1)register_shutdown_function PHP自身功能
2)使用中间件laravel并实现照亮\合同\路由\ TerminableMiddleware接口
你需要工具
public function terminate($request, $response)
为TerminableMiddleware接口功能。 终止函数将在脚本结尾被调用。
例如laravel使用TerminableMiddleware接口在照亮\会话\中间件\ StartSession类在脚本的端部来存储会话数据
代码示例形式源
public function terminate($request, $response)
{
if ($this->sessionConfigured() && ! $this->usingCookieSessions())
{
$this->manager->driver()->save();
}
}
谢谢,顺便说一句,它是'TerminableInterface'而不是'TerminableMiddleware'。 – Javid
Laravel 5仍然是测试版软件,所以当事情破裂时不要感到惊讶。你可能会收到这个错误,因为虽然
Application::shutdown(function(){});
是建立一个有效的方式为关机事件处理程序,即使在Laravel 4,它不是有效的方式来建立在Laravel 5关闭事件侦听器。
这可能是因为Laravel 5朝着annotated event system移动,也可能是因为在Laravel 5
临时故障的发展而这个错误你没有任何的代码? – Rizier123