[13.x] Add incremental readable env encryption - #61503
Open
mathiasgrimm wants to merge 7 commits into
Open
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
mathiasgrimm
marked this pull request as ready for review
September 9, 2026 14:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
--incrementaltoenv:encrypt --readableso changing one value does not change every encrypted line in the PR diff.Docs: laravel/docs#11357.
Unchanged values keep their ciphertext. New or changed values are encrypted, and deleted variables are removed. The option creates the encrypted file if it is missing and does not require
--force.If the existing file is not readable or cannot be decrypted, the command fails without overwriting it. Regular
--forcestill re-encrypts everything.Before / after
For example, changing only
DB_PASSWORD=1toDB_PASSWORD=2produces these diffs in the encrypted file. Ciphertext is shown as placeholders for readability.Before, with
--readable --force, every encrypted entry changes:After, with
--readable --incremental, only the password entry changes:Try it locally
Use a disposable Laravel app running this branch. All values below are for testing.
REVIEW_KEYis a dummy 32-byte key for testing only.Create
.env.review:Create the encrypted baseline:
Each encryption command below should print:
Other command output is omitted. Ciphertext in the example diffs is shortened for readability.
No changes
php artisan env:encrypt --env=review --readable --incremental --key="$REVIEW_KEY" diff -u .env.review.encrypted.baseline .env.review.encryptedNo diff is produced.
Change only
DB_PASSWORDChange
DB_PASSWORD=1toDB_PASSWORD=2in.env.review, then run:php artisan env:encrypt --env=review --readable --incremental --key="$REVIEW_KEY" diff -u .env.review.encrypted.baseline .env.review.encryptedOnly the password entry changes:
Delete
DB_PASSWORDRestore the baseline first:
Remove the
DB_PASSWORDline from.env.review, then run:php artisan env:encrypt --env=review --readable --incremental --key="$REVIEW_KEY" diff -u .env.review.encrypted.baseline .env.review.encryptedOnly that entry is removed:
APP_NAME=<unchanged ciphertext> DB_HOST=<unchanged ciphertext> -DB_PASSWORD=<previous ciphertext>diffreturns exit code1when it finds differences; that is expected for the last two examples.