我的问题是:如何让 Frozennode 管理员在 Laravel 维护模式下正常运行?
这就是我在 global.php 中得到的
App::down(function()
{
return Response::view('maintenance', array(), 503);
});
谢谢!
我的问题是:如何让 Frozennode 管理员在 Laravel 维护模式下正常运行?
这就是我在 global.php 中得到的
App::down(function()
{
return Response::view('maintenance', array(), 503);
});
谢谢!
我已经挖到了核心,你没有办法做到。Laravel 检查文件夹中命名down
的app/storage/meta
文件,如果它在那里,Laravel 甚至不会调用路由,它只会显示错误页面。
这是isDownForMaintenance
来自 laravel 的功能:
public function isDownForMaintenance()
{
return file_exists($this['path.storage'].'/meta/down');
}
无法进行任何配置。
laravelish“维护模式”的另一种方法是在 中设置一个新值config/app.php
,添加:
'maintenance' => true,
然后将其添加到您的before
过滤器中:
App::before(function($request)
{
if(
Config::get('app.maintenance') &&
Request::segment(1) != 'admin' // This will work for all admin routes
// Other exception URLs
)
return Response::make(View::make('hello'), 503);
});
然后只需设置:
'maintenance' => true,
返回正常模式
其实还有另一种方式,更直接。正如您在 Laravel文档中所读到的,从闭包返回 NULL 将使 Laravel 忽略特定请求:
如果传递给 down 方法的闭包返回 NULL,则该请求将忽略维护模式。
因此,对于以 admin 开头的路由,您可以执行以下操作:
App::down(function()
{
// requests beginning with 'admin' will bypass 'down' mode
if(Request::is('admin*')) {
return null;
}
// all other routes: default 'down' response
return Response::view('maintenance', array(), 503);
});