laravel / laravel/framework

Down command creates files when using cache driver for maintenance mode

Open
#53,278 10 comments 1 reaction 0 assignees View on GitHub
needs more info
Dominant language
PHP
Stars
34.9k
Forks
12k
Avg merge
17h 57m
Merged PRs (30d)
182

Description

### 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](https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Console/stubs/maintenance-mode.stub#L4-L6), which is the case when you're using the cache driver, so basically it is useless.

Example of when this is an issue:

1. 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.
2. 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 https://github.com/laravel/framework/pull/53228, but that wasn't accepted.

### Steps To Reproduce

1. Make sure your cache store isn't file based;
2. Set the maintenance mode driver to cache;
3. Make the `storage` directory read-only;
4. Run `php artisan down`;
5. See that the command fails because it can't create the maintenance file.

Contributor guide

Open the contributing guide

Research direction

Start with the maintenance-mode stub at src/Illuminate/Foundation/Console/stubs/maintenance-mode.stub and trace the php artisan down command when the maintenance driver is set to cache. Reproduce the read-only storage failure, then verify that cache-based maintenance mode no longer requires framework/maintenance.php while other maintenance modes still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.