-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Improved Maintenance Mode #33560
Conversation
That is awesome Mr @taylorotwell always wanted this kinda thing instead of doing “private” routes. |
I love this so much :) |
This is awesome 🙌 |
This is fantastic, thanks! |
This is a good one 👍 |
How will this work in environments like Vapor as we can't persist a file to the file system? |
* Determine if the incoming request has a maintenance mode bypass cookie. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add @param array $data
*/ | ||
protected function redirectPath() | ||
{ | ||
if ($this->option('redirect') && $this->option('redirect') !== '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note - looks good but generally not a fan of directly comparing strings, would prefer str cmp methods instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
FTR, there's exactly one strcmp
in the entire framework AFAICS. I didn't bother to count the direct string comparison checks 😄
I can get |
This PR implements a much improved maintenance mode.
Prerendered Templates
One main deficiency of the previous implementation was the entire framework has to be booted in order to render the maintenance page. This could cause various problems if Composer was in the middle of updating dependencies, an infrastructure component was down, etc.
The new
render
option of thedown
command allows you to prerender a view. In addition, a newbootstrap/maintenance.php
file is written. This file is loaded before Composer in the framework'sindex.php
file and is able to render the template and exit with zero dependencies. Composer and Laravel are never loaded.Secret Bypass Instead Of IP Allow List
The IP allow list has been removed in favor of a secret bypass route. The IP white list isn't practical for many applications. You may now use the
secret
option of thedown
command:Once the application is in maintenance mode, you may navigate to the secret's value as a route. For example:
https://example.com/MvYgEHudaikRaX4JRcyh
The maintenance middleware will intercept this request and issue a maintenance mode bypass cookie to the user and redirect them to
/
, allowing them to access the application and bypass maintenance mode for 12 hours. The cookie contains a HMAC signed expiration time.Redirects
A new
redirect
option has been added to thedown
command to instruct all paths of the application to redirect to the given path during maintenance:Status Code
A new
status
option has been added to thedown
command to allow the status code to be customized. The default is 503. You can combine this with theredirect
andsecret
options to still show a normal marketing / "coming soon" site but allow the real application to be accessed via the secret...