Laravel 5 maintenance mode turn on without artisan

后端 未结 6 1399
-上瘾入骨i
-上瘾入骨i 2021-01-31 18:38

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:

相关标签:
6条回答
  • 2021-01-31 18:48

    just put

    Artisan::call('up');
    

    without route function.

    0 讨论(0)
  • 2021-01-31 18:49

    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;
    
    0 讨论(0)
  • 2021-01-31 18:57

    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.

    0 讨论(0)
  • 2021-01-31 18:57

    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.

    0 讨论(0)
  • 2021-01-31 18:58

    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.

    0 讨论(0)
  • 2021-01-31 19:06

    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.

    0 讨论(0)
提交回复
热议问题