framework
framework copied to clipboard
Regex Pattern in artisan key:generate
- Laravel Version: 9.19
- PHP Version: 8.0.2
Description:
Given the following .env
...
APP_NAME=Laravel
APP_KEY=
...
... artisan key:generate
will yield...
APP_NAME=Laravel
APP_KEY=base64:133eb1bde70e4ba388bdf74e4ac95cbd=
This includes the trailing =
character every time. I don't think it causes an issue, but the output looked strange to me. If the .env
file is quoted as APP_KEY=""
, the command suffixes the =""
chars after the artisan-generated app key. When the APP_KEY
string is missing from .env
, the key isn't written to the .env
file at all.
Is this the intended behavior of the command?
https://github.com/laravel/framework/blob/053840f579cf01d353d81333802afced79b1c0af/src/Illuminate/Foundation/Console/KeyGenerateCommand.php#L98-L124
Steps To Reproduce:
Use a .env
formatted similarly to the one below, or omit the APP_KEY
string from the .env
file entirely, then run php artisan key:generate
.
APP_NAME=Laravel
APP_KEY=
...
The padding makes sense, but what caught me off-guard was that it retains the additional characters after the =
as well. So if I initially have APP_KEY=""
, then I get APP_KEY=...=""
. If the APP_KEY
entry is missing from .env
entirely, then it isn't written at all.
Is it worth opening a PR for this or is this not something that would be considered an actual bug requiring a fix?
Please don't remove APP_KEY
from your env file.