不使用Artisan的维护模式? [英] Maintenance Mode without using Artisan?
问题描述
我只是想知道是否有人可以在不使用Artisan的情况下在laravel网站上激活维护模式?我没有对服务器的命令行访问权限,因此如果不先在本地站点上对其进行更新,然后将所做的更改推送到服务器,就无法使用Artisan.我是否可以添加一个主路由,以拒绝访问其他任何路由?
I'm just wondering if anyone know's if there's a way to activate maintenance mode on a laravel website without using Artisan? I don't have command line access to the server so I can't use Artisan without first updating it on my local site and then push the changes to the server. Is there maybe a master Route that I can add that will deny access to any other routes?
谢谢!
推荐答案
您可以从应用程序中调用artisan:
You can just call artisan from your application:
Artisan::call('down');
Artisan::call('up');
但是,由于您的应用已关闭,因此您无权启动它.您可以自己创建功能:
But since you'll not have access to get your app up because it's down. You can create the functionality yourself:
用于关闭它的路由,必须对此用户进行身份验证:
A route for shut it down, user must be authenticated to do this:
Route::group(array('before' => 'auth'), function()
{
Route::get('shut/the/application/down', function()
{
touch(storage_path().'/meta/my.down');
});
});
将其备份的方法:
Route::get('bring/the/application/back/up', function()
{
@unlink(storage_path().'/meta/my.down');
});
用于检查其是否正常的过滤器:
A filter to check if it's up:
Route::filter('applicationIsUp', function()
{
if (file_exists($this['path.storage'].'/meta/my.down'))
{
return Redirect::to('site/is/down');
}
});
将其备份的方法:
Route::get('bring/the/application/back/up', function()
{
@unlink(storage_path().'/meta/my.down');
});
当您的网站关闭时显示优美景色的路线
A route to show a pretty view when your site is down
Route::get('site/is/down', function()
{
return View::make('views.site.down');
});
这篇关于不使用Artisan的维护模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!