Laravel - artisan down / Maintenance Mode except own IP

后端 未结 6 1854
Happy的楠姐
Happy的楠姐 2021-02-14 16:38

Currently i am using Laravel5. My question is if if i use the Maintenance mode with

php artisan down

how can say \"the application is down for

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-14 17:26

    In Laravel 5 you have to create your own middleware. Create a file in app/Http/Middleware/CheckForMaintenanceMode.php You can choose of course any filename.

    app = $app;
        }
    
        public function handle(Request $request, Closure $next)
        {
            if ($this->app->isDownForMaintenance() && 
                !in_array($request->getClientIp(), ['8.8.8.8', '8.8.4.4']))
            {
                $maintenanceMode = new MaintenanceMode($this->app);
                return $maintenanceMode->handle($request, $next);
            }
    
            return $next($request);
        }
    
    }
    

    In your app/Http/Kernel.php change

    'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode'
    

    to

    'App\Http\Middleware\CheckForMaintenanceMode'
    

提交回复
热议问题