Is there any possibility to turn on and turn off Laravel 5 maintenance without php artisan up and down commands when my website is being hosted ?
What I\'ve done:
just put
Artisan::call('up');
without route function.
In order to make your site live again using an url, you can create a live.php file which you put in laravel's public folder and then visit http://your.domain/live.php .
In the live.php file you need something like this: (check your projects directory structure if you don't use the default public folder!)
<?php
unlink(dirname(__FILE__) . "/../storage/framework/down");
header("Location: your.domain");
die;
I think the right answer is missing here.. You could add your route to app/http/middleware/CheckForMaintenanceMode.php
protected $except = [
//here
];
So It never would be off.
when you run artisan down. site is not available so when try to call up, your IP can't access site. you must call down with your IP exception.
php artisan down --allow=127.0.0.1 --allow=192.168.0.0/16
or add ::1 to local.
to make that in route without command try to save this command in specific one and call it.
Laravel 8 introduced secret
in maintenance mode, in which you can bypass the maintenance mode by providing a secret, then your Artisan::call
would work.
You could add your routes to the $except
var in CheckForMaintenanceMode
middleware to bypass the check. Then your site/live
route would work just fine.
If your project is already down, you cannot call another function.
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. When you want to take your project live again, just remove the file.