Anindit Karmakar
Anindit Karmakar

Reputation: 835

Laravel 4 bypass maintenance mode for a route

I have put my application down for maintenance using php artisan down command.

My custom maintenance page as a email input to accept the email from the user and store in my database to notify the user when the site is back up and running again.

But when I submit the form using POST, I get redirected to the maintenance mode page.

I want one particular route to bypass the maintenance mode. Is it possible?

Upvotes: 4

Views: 1593

Answers (1)

Anindit Karmakar
Anindit Karmakar

Reputation: 835

Okay so I found a way to go about this problem.

In my app/routes file, I have a route as follows:

// app/routes.php
Route::resource('subscriber', 'SubscriberController');

Now this will route will match any request URI for the form subscriber*

In my app/start/global.php file, I did the following inside App::down()

// app/start/global.php
App::down(function() {

    if(Request::is('subscriber*')) {
        return null;
    }

    return Response::view('maintenance', array(), 503);
})

Now only for URIs of starting with subscriber, the maintenance mode page will not be displayed.

:D

Upvotes: 5

Related Questions