Skip to content

[9.x] Show error if key:generate artisan command fails#44927

Merged
taylorotwell merged 2 commits intolaravel:9.xfrom
mbardelmeijer:fix/return-error-when-app-key-set-failed
Nov 14, 2022
Merged

[9.x] Show error if key:generate artisan command fails#44927
taylorotwell merged 2 commits intolaravel:9.xfrom
mbardelmeijer:fix/return-error-when-app-key-set-failed

Conversation

@mbardelmeijer
Copy link
Copy Markdown
Contributor

This PR changes that if the artisan key:generate fails, an error message is shown.

This is most common when the .env file is missing an APP_KEY= empty placeholder. In this case, the preg_replace call will return the input as-is. If that happened, an error is shown instead of showing the incorrect Application key set successfully.

Fixes #44917

Copy link
Copy Markdown
Member

@driesvints driesvints left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one 👍

@taylorotwell taylorotwell merged commit 5a36ee9 into laravel:9.x Nov 14, 2022
@LukeTowers
Copy link
Copy Markdown
Contributor

@driesvints @mbardelmeijer is there any interest in using something like the Laravel Config Writer provided by @wintercms (see https://github.com/wintercms/laravel-config-writer/blob/main/README.md#environment-files) to more reliably handle these issues rather than just failing?

@driesvints
Copy link
Copy Markdown
Member

@LukeTowers appreciate it but I don't think so no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

APP_KEY not set when not in .env despite "Application key set" message

4 participants