Categories
Laravel

Laravel 5 Maintenance Mode

Enabling and disabling maintenance mode in Laravel 5 is simple, you just need to issue following artisan commands –

  • To enable maintenance mode php artisan down.
  • To disable maintenance mode php artisan up.

That is it. If you want to allow the application to listed IPs, even when the application is in maintenance mode. We need to override the default middleware : \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php (default laravel5 uses).

Laravel 5 Maintenance Mode
First we need to get current user ip address by using laravel5 powerful request object method $this->request->getClientIp()

Than copy the default laravel5 maintenance middleware in \app\Http\Middleware\CheckForMaintenanceMode.php and make changes as shown below –

Now open \app\Http\Kernel.php file and comment out default middleware and add our custom middleware

Maintenance Mode Response Template – The default template for maintenance mode responses is located in resources/views/errors/503.blade.php.

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

Leave a Reply

Your email address will not be published. Required fields are marked *