当前位置:网站首页>Improvement of maintenance mode of laravel8 update

Improvement of maintenance mode of laravel8 update

2020-11-07 20:55:58 Shenbing general

Original link :https://www.wjcms.net/archive...

Yes php artisan down The command makes some very nice improvements .

In previous releases , In order to allow only certain people to visit the site , You have to use the whitelist function , As mentioned in this blog post :

Pre render maintenance mode templates are now supported , And it eliminates the chance for end users to encounter errors during maintenance mode . however , So , The following lines must be added to your file . These lines should be placed directly under the existing constant definition :public/index.phpLARAVEL_START

define('LARAVEL_START', microtime(true));

if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
    require __DIR__.'/../storage/framework/maintenance.php';
}

notes :php artisan down --message Has been removed

How to create custom Laravel Maintenance page

Use Laravel 8, You can have a secret , Instead of using IP White list . To configure it , All you have to do is :

php artisan down --secret=YOUR_SECRET_HERE

Make sure YOUR_SECRET_HERE Replace parts with safe chords !

Then visit the website in maintenance mode , Please visit Your domain name +/YOUR_SECRET_HERE, This will generate a secret cookie, So you can browse the website as usual !

This is a great way to put your site in maintenance mode , But it still allows some people to access it !

The php artisan down Another great addition to the command is that you can pre render maintenance pages , So even if you run composer update end user , You can still see the maintenance page , Not some mistakes .

So , Just run :

php artisan down --render="errors::503"

such , You can do extensive maintenance , You don't have to worry about users seeing some strange mistakes , And don't worry about the page looking friendly .

The cool thing is , You can put the logo together . for example , You can run the following command to add secrets to the displayed page and change the status code at the same time :

php artisan down --render="errors::503" --status=200 --secret=YOUR_SECRET_HERE

版权声明
本文为[Shenbing general]所创,转载请带上原文链接,感谢