diff --git a/src/Application.php b/src/Application.php index 6e9c4fd8..5ddbea87 100644 --- a/src/Application.php +++ b/src/Application.php @@ -186,7 +186,7 @@ public function environment() */ public function isDownForMaintenance() { - return false; + return file_exists($this->storagePath().DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'down'); } /** diff --git a/src/Console/Commands/DownCommand.php b/src/Console/Commands/DownCommand.php new file mode 100644 index 00000000..ac180201 --- /dev/null +++ b/src/Console/Commands/DownCommand.php @@ -0,0 +1,33 @@ +laravel->storagePath().'/framework/down'); + + $this->comment('Application is now in maintenance mode.'); + } + +} diff --git a/src/Console/Commands/UpCommand.php b/src/Console/Commands/UpCommand.php new file mode 100644 index 00000000..09e5a2fd --- /dev/null +++ b/src/Console/Commands/UpCommand.php @@ -0,0 +1,33 @@ +laravel->storagePath().'/framework/down'); + + $this->info('Application is now live.'); + } + +} diff --git a/src/Http/Middleware/CheckForMaintenanceMode.php b/src/Http/Middleware/CheckForMaintenanceMode.php new file mode 100644 index 00000000..1dd4fd86 --- /dev/null +++ b/src/Http/Middleware/CheckForMaintenanceMode.php @@ -0,0 +1,107 @@ +app = $app; + $this->view = $view; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * + * @return mixed + */ + public function handle(Request $request, Closure $next) + { + if ($this->app->isDownForMaintenance()) { + return new Response($this->maintenance(), 503); + } + + return $next($request); + } + + public function maintenance() + { + return " + + Maintenance. + + + + + + +
+
+
Maintenance, back soon.
+
+
+ + + "; + } +}