不使用 Artisan 的维护模式? [英] Maintenance Mode without using Artisan?

查看:15
本文介绍了不使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆