Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maintenance Mode without using 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?

Thanks!

like image 493
Steve Bauman Avatar asked Jan 10 '14 15:01

Steve Bauman


People also ask

What artisan command bring the application out of maintenance mode?

Artisan::call('down'); To bring the application remove the file or call the up command, as shown above.

Which command we can use to Laravel site in maintenance mode?

To perform maintenance mode on Laravel, run the down Artisan command.

What is php artisan down?

What happens after you run php artisan down is that it creates a file named down inside storage/framework . After running php artisan up the file is removed. You can create the file manually inside storage/framework . It will down your project.


1 Answers

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');     });  }); 

A route to bring it back up:

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');     } }); 

A route to bring it back up:

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'); }); 
like image 75
Antonio Carlos Ribeiro Avatar answered Oct 02 '22 13:10

Antonio Carlos Ribeiro