Switching Maintenance Mode to Production And Vice Versa Quickly in laravel 4.2

Submitted by dhrubo001 - 4 years ago

Switching Maintenance Mode to Production And Vice Versa Quickly in laravel 4.2

Create a filter first
1. In filters.php
Route::filter('mode',function(){

    if(Config::get('maintenance.mode') == 0)
     {
		 //return View::make('pages.extra.maintenance_mode');
         return 'We are under maintenance mode';
	 }
});

2. Create a maintenance.php in app/config

<?php

 return array(
   
   /*
    |--------------------------------------------------------------------------
	| Manual Maintenance Mode
	|--------------------------------------------------------------------------
	|
	| This is our manual maintenance mode 0=Maintenanace, 1= Live.
	|
	| 
	|
	*/
   
   'mode' => 0,
 );
 
 
 3. Then add all the routes  within the filter "MODE"
 
 Route::group(array('before'=>'mode'),function(){
    
    /* ALL YOUR ROUTES GOES HERE */
	 Route::get('/',function(){
		return 'Home Page';
	  });
      
      Route::get('/another-route',function(){
    	return 'Another Page';
	  });
      
      /////////////////
});


Just change the mode from 0 = Maintenance 1 = Production


And do not forget to create a maintenance view if you want to load a view