Maintenance Mode without using Artisan?

后端 未结 5 576
日久生厌
日久生厌 2020-12-02 10:25

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 ser

5条回答
  •  日久生厌
    2020-12-02 10:52

    This is for Laravel 4.1 and below

    Laravel 5 downfile is in storage/framework/down - thanks @ruuter.

    Taking a look at the DownCommand class for Artisan, it seems to create a new file within the app/storage/meta folder.

    Heres the DownCommand fire method.

    public function fire()
    {
        touch($this->laravel['path.storage'].'/meta/down');
    
        $this->comment('Application is now in maintenance mode.');
    }
    

    And the corresponding UpCommand fire method.

    public function fire()
    {
        @unlink($this->laravel['path.storage'].'/meta/down');
    
        $this->info('Application is now live.');
    }
    

    These files are located in vendor/laravel/framework/src/Illuminate/Foundation/Console.

    It specifically creates a file called down in app/storage/meta.

    You could create an authorized route / controller action to replicate these commands.

    Note Sjaak Trekhaa's comment below, that is the method I would use now that I've been reminded of it!

提交回复
热议问题