Laravel - Maintenance mode just for some urls

laravel maintenance mode without artisan
laravel maintenance mode manual
laravel maintenance mode except ip
how to show maintenance page in laravel
how to set maintenance mode in laravel
laravel cached config
laravel show maintenance
laravel take site down

I need to use the Maintenance mode using the artisan command "down", but just for some urls...

In my case, i want that all urls that starts with "/admin/*" continue working.

Is there a solution?

Take a look at app/http/middleware/CheckForMaintenanceMode.php There is a URI Array:

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;

class CheckForMaintenanceMode extends Middleware
{
    /**
     * The URIs that should be reachable while maintenance mode is enabled.
     *
     * @var array
     */
    protected $except = [
        //
    ];
}

array-example :

    protected $except = [
        'api/customers',
        'api/user'
    ];

maintenance mode (excluding some routes), I know laravel comes with a maintenance mode. Accepting controller actions or wildcard URLs would be great ;D. Works now but At the moment it seems like it just checks if the route contains "admin", if this returns true the� # Maintenance Mode. When deploying a Laravel application using a traditional VPS like those managed by Laravel Forge, you may have used the php artisan down command to place your application in "maintenance mode". To place a Vapor environment in maintenance mode, you may use the Vapor UI or the down CLI command:

I'm also using this to check if any of the URL segments is API, to let those URL's to work properly.

public function handle($request, Closure $next) {
    if ($this->app->isDownForMaintenance() &&  !in_array($_SERVER['REMOTE_ADDR'],['192.168.240.18','127x.0.0.1'])) {

        /** if URL contains API, disable continue, don't keep maintenance */
        if(in_array('api',$request->segments())){
            return $next($request);
        }

        throw new HttpException(503);
    }

    return $next($request);
}

[Feature Proposal] Except routes from maintenance mode � Issue , Background In some countries (especially EU- Laravel's maintenance mode is currently just a binary state: Either the whole Laravel� Maintenance Mode. Sometimes you may need to update some configuration values or perform maintenance on your website. In such cases, keeping it in maintenance mode, makes it easier for you. Such web applications which are kept in maintenance mode, throw an exception namely MaintenanceModeException with a status code of 503.

Suggest by @lukasgeiter i created a middleware that tests my url... That`s my code:

<?php namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\RedirectResponse;

class Maintanance {
    public function handle($request, Closure $next){
        if($request->is('admin*') || $request->is('maintanance')){
            return $next($request);
        }else{
            return new RedirectResponse(url('/maintanance'));
        }
    }
}

After that i created a route that show de maintenance view:

Route::get('maintanance', function(){
    return view('errors.503');
});

Now i can call the command "up" and the application still under maintenance, but the /admin urls...

Configuration - Laravel, It contains several options such as timezone and locale that you may wish to change To enable maintenance mode, simply execute the down Artisan command: The framework ships with a public/.htaccess file that is used to allow URLs� The names you can pass here in 3rd parameters are for named routes and don't have anything in common with urls, if you used something named routes as you showed you can now use: URL::route('nouveau', 1);

I did something like this before, but not using the php artisan down command.

The first thing the kernel does before even loading the application is checking if your site is in maintenance mode.

So, you won't be able to reach your controller or even your routes with php artisan down.

You might want to do your own command likephp artisan softdown which create a file somewhere in your /storage dir which will tell to your app the app is in 'soft down' mode. And of course, make another one called softup

Then, in your routes, you'll wrap all your frontend routes with an IF which checks if the file exists, or not.

If so, then you return the view maintenance.blade.php.

Work on a Laravel Live Site while in Maintenance Mode – Yet , Responses � Views � URL Generation � Session � Validation � Error Handling Accessing Configuration Values; Configuration Caching; Maintenance Mode All variables in your .env files are parsed as strings, so some reserved values have that you are only calling the env function from within your configuration files. If you are working on your live site and want to turn on maintenance mode in laravel, you just need a command run and done. All this can handle via php artisan commands. You can learn about artisan commands here. Turn on maintenance mode in laravel You just need to grab your application path where laravel application … Continue reading →

How to enable or disable maintenance mode in Laravel?, Work on a Laravel Live Site while in Maintenance Mode using cookies. Some information might be out of date, as I don't always update older articles. In Http\ Kernel.php simply insert your file in the $middleware array and Keep URL and query parameters using manual pagination in Laravel. Vapor requires that your application be compatible with PHP 7.3+ and Laravel 6.0+. # Account Creation. Before integrating Vapor into your application, you should create a Vapor account. If you are just collaborating with others on their projects, you are not required to have a Vapor subscription.

Maintenance mode - redirect/ forward all requests, Enable maintenance mode. php artisan How to pass URL param in Laravel? Hello, First you Hello, This is simple you just need to READ� To enable maintenance mode, simply execute the down Artisan command: .. php artisan down To disable maintenance mode, use the up command: .. php artisan up To show a custom view when your application is in maintenance mode, you may add something like the following to your application’s app/start/global.php file:

Significance of Laravel Maintenance & Support Services, Some built-in router functions maybe ? In your bootstrap file just redirect everything to your maintenance page parameter) and I can't seem to get a proper "catchall" to deal with bad urls. If you want a cli command like laravel, you just need to implement phalcon-cli and create a task turn the flag on/off. If you have API endpoint which performs some operations but has no response, so you wanna return just "everything went ok", you may return 204 status code "No content". In Laravel, it's easy: return response()->noContent();.

Comments
  • I guess the easiest way would be to create a middleware and check if the URL starts with admin or not. However I'm not going to do all the hard work for you. Please try yourself and come back to this question if you encounter a problem you can't solve yourself
  • No idea why this is downvoted, but this is actually the native answer. If you, as given in the example, extend the original middleware, then override the $except array to add the routes you require to be accessible after artisan down is executed.