-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Down command creates files when using cache driver for maintenance mode #53278
Comments
Hey! 👋 You're right—Laravel’s php artisan down command creates the framework/maintenance.php file even in cache-based maintenance mode. This file isn’t really necessary if you’re relying on the cache driver for maintenance status. One option is to create a custom command to enable maintenance mode using only the cache without creating maintenance.php. Here’s an example: php use Illuminate\Support\Facades\Cache; class CustomDownCommand extends Command
} This way, only the cache is used, and maintenance.php won’t be created. Hope this helps! 😊 |
Thank you for raising this issue! I understand the challenges faced, particularly in multi-server environments or read-only filesystems, where creating unnecessary files can disrupt workflows. To address this, here are a few thoughts: Workaround: `use Illuminate\Support\Facades\Cache; class CustomDownCommand extends Command
} Proposal for Core Behavior: Documentation: I’d be happy to assist with refining this idea or contributing a PR for the documentation. Let me know how I can help! 😊 |
It looks like you're facing an issue with Laravel's maintenance mode when using the cache driver. The problem arises because the php artisan down command attempts to create a framework/maintenance.php file, which is not necessary when the cache driver is used, especially in multi-server environments or when the storage directory is read-only. To address this, you could consider the following approaches:
|
Hi @JaZo, Please update APP_MAINTENANCE_DRIVER to cache and APP_MAINTENANCE_STORE to database. This will allow us to manage Maintenance Mode across multiple servers effectively. @ismaildasci @devriazul @mhshagor @crynobone please check this out. |
Thanks all for the responses! Sure I can create my own command to "fix" this, but in my opinion it should be fixed in the framework itself. @pandiselvamm, using the cache driver for maintenance mode works fine, the problem is that it creates the |
@JaZo I've no idea why this is marked as @crynobone when you run framework/src/Illuminate/Foundation/Console/DownCommand.php Lines 55 to 58 in 2c72603
The framework/src/Illuminate/Foundation/Console/UpCommand.php Lines 43 to 45 in 2c72603
When you use the
Ideally, this file shouldn't be created for anything but the |
@JaZo if you want a quick fix, you can do this in a service provider Event::listen(Illuminate\Foundation\Events\MaintenanceModeEnabled::class, function () {
if (is_file(storage_path('framework/maintenance.php'))) {
unlink(storage_path('framework/maintenance.php'));
}
}); |
Laravel Version
11.23.5
PHP Version
8.2.24
Database Driver & Version
No response
Description
When you're using the cache based maintenance mode, Laravel still tries to create the
framework/maintenance.php
file. However, this file does nothing when there's no down-file, which is the case when you're using the cache driver, so basically it is useless.Example of when this is an issue:
In both these situations the cache driver should suffice, but currently it has this issue.
N.B. I proposed a solution in #53228, but that wasn't accepted.
Steps To Reproduce
storage
directory read-only;php artisan down
;The text was updated successfully, but these errors were encountered: