You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
When running a multi server environment, only the server where the down command is ran, will have the maintenance file and the others don't.
When running on a read-only filesystem, the down command will error as the file can't be created.
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
Make sure your cache store isn't file based;
Set the maintenance mode driver to cache;
Make the storage directory read-only;
Run php artisan down;
See that the command fails because it can't create the maintenance file.
The text was updated successfully, but these errors were encountered:
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.
Possible Workaround
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;
use Illuminate\Console\Command;
class CustomDownCommand extends Command
{
protected $signature = 'custom:down';
protected $description = 'Put the app in maintenance mode (cache-based only)';
public function handle()
{
Cache::put('maintenance_mode', true, now()->addHours(24)); // 24-hour maintenance mode
$this->info('Maintenance mode enabled without file.');
}
}
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:
A custom command like the one suggested by @ismaildasci is a great temporary solution. For example:
`use Illuminate\Support\Facades\Cache;
use Illuminate\Console\Command;
class CustomDownCommand extends Command
{
protected $signature = 'custom:down';
protected $description = 'Put the app in maintenance mode (cache-based only)';
public function handle()
{
Cache::put('maintenance_mode', true, now()->addHours(24)); // 24-hour maintenance mode
$this->info('Maintenance mode enabled without file.');
}
}
`
This ensures maintenance mode is activated using the cache driver without attempting to create the maintenance.php file.
Proposal for Core Behavior:
Laravel could check the maintenance mode driver and skip creating the framework/maintenance.php file entirely if the driver is set to cache. This change would maintain backward compatibility while streamlining behavior for cache-based setups.
Documentation:
If the core behavior remains unchanged, it would be helpful to update the documentation or migration guides to note this behavior and provide recommendations for multi-server or read-only environments.
I’d be happy to assist with refining this idea or contributing a PR for the documentation. Let me know how I can help! 😊
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: