Laravel 5 maintenance mode turns on without wizards

Is it possible to turn Laravel 5 service on and off without php artisan up and down commands when my site is hosted?

What I've done:

Route::get('site/shutdown', function(){ return Artisan::call('down'); }); Route::get('site/live', function(){ return Artisan::call('up'); }); 

The first route is working fine. But when I call the site / live, the site is still turned off. What can cause this problem?

+12
source share
4 answers

If your project is already disabled, you cannot call another function.

What happened after running php artisan down . It creates a file called down inside storage/framework . After running php artisan up it deletes the file.

You can create the file manually inside storage/framework . This is according to your design. If you want to renew your project again, simply delete the file.

+21
source

To make your site live again using the URL, you can create a live.php file that you put in the laravel public folder, and then visit http: //your.domain/live.php .

In the live.php file, you need something like this: (check the project directory structure if you are not using the default public folder!)

 <?php unlink(dirname(__FILE__) . "/../storage/framework/down"); header("Location: your.domain"); die; 
+2
source

when you start the artisan. the site is unavailable, so when you try to call, your IP cannot access the site. You must call with your IP exception.

 php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16 

or add :: 1 to local.

To do this in a route without a command, try saving this command to a specific one and calling it.

0
source

just put

 Artisan::call('up'); 

without route function.

0
source

Source: https://habr.com/ru/post/1240735/


All Articles