Activating maintenance mode

When we do php artisan down in the command it just creates an empty file in app/storage/meta directory called ”down”.

You can call artisan from your application:

Artisan::call(‘down’);

Artisan::call(‘up’);

If you don’t have access to server you can create the functionality. If the user is authenticated you can shut down using the route.

Route::group(array('before' => 'auth'), function()

{


    Route::get('shut/the/application/down', function() 

    {

        touch(storage_path().'/meta/my.down');

    });


});

Then create another route to revert it as given below.

Route::get('bring/the/application/back/up', function() 

{

    @unlink(storage_path().'/meta/my.down');

});

Add a filter to check if its up

Route::filter('applicationIsUp', function()

{

    if (file_exists($this['path.storage'].'/meta/my.down'))

    {

        return Redirect::to('site/is/down');

    }

});

The route to bring it back :

Route::get('bring/the/application/back/up', function() 

{

    @unlink(storage_path().'/meta/my.down');

});

The route to show the view when the site is down:

Route::get('site/is/down', function() 

{

    return View::make('views.site.down');

});