Laravel Access to Maintenance Mode using Secret Code

Published on Jul 09, 2022

Hello Artisans, Toady I'll talk about one of the new features of Laravel, access to application through maintenance mode token. So, previously if we want to go to the maintenance mode and if anyone needs a access to the application, we need to allow the specific IP address via the below command.

php artisan down --allow=127.0.0.1

It's quite an complex, because every time you need to check the IP address and then request for admin to access the application with your IP. But here comes the secret token. Where you can set your application to the maintenance mode using a secret key with artisan down command. So, your final command will be

php artisan down --secret="shoutsdev"

What will command is do, that you application go to the maintenance mode and this secret which we provide as an example shoutsdev, it will set with a token under storage/framework/down, where you can find all of your information. The file looks like below.

When you will share this token with anyone, who wants to access to you r application he can visit to your application by entering the below link

www.yourdomain.com/shoutsdev

Behind The Scene

Larvel store the key in your browser cache called laravel_maintenance which let's you access the application. And if you clear the cookies of you r browser you'll lose the access to your application.

That's it for today. Hope you've enjoyed this tutorial. Thanks for reading. 🙂

Comments (0)