Skip to content

refactor: improve UX on key:generate#10181

Open
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
paulbalandan:key-generate-ux
Open

refactor: improve UX on key:generate#10181
paulbalandan wants to merge 1 commit intocodeigniter4:4.8from
paulbalandan:key-generate-ux

Conversation

@paulbalandan
Copy link
Copy Markdown
Member

Description
Brings key:generate in line with the UX pattern established by #10126 (logs:clear) and #10174 (key:rotate):

  • Declining the overwrite prompt interactively now returns EXIT_SUCCESS (with a yellow Setting new encryption key cancelled. notice) instead of treating a valid user choice as an error.
  • The non-interactive abort message collapses to one line: Setting new encryption key aborted: pass --force to overwrite the existing key in non-interactive mode.
  • Success and write-failure messages now name the .env path via clean_path().
  • The "both env and .env missing" branch moved out of writeNewEncryptionKeyToFile() into execute(), so the inline-fallback ("here's your new key") no longer chains into a redundant "Error in setting new encryption key to .env file." right after.
  • Fixed CLI::writeCLI::error on the write-failure path so the message goes to STDERR.
  • Added an is_writable() guard in writeNewEncryptionKeyToFile() (parallels the RotateKey hardening; lets the failure path be exercised cleanly in tests).

The exit-code change is documented under Behavior Changes in the v4.8.0 changelog.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@github-actions github-actions Bot added the 4.8 PRs that target the `4.8` branch. label May 10, 2026
@paulbalandan paulbalandan added the refactor Pull requests that refactor code label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.8 PRs that target the `4.8` branch. refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants