Skip to content

How to update encrypted .env files

In case you need to change an environment variable (example is for staging environment, please use the environment name you need to update):

  1. Get an encryption key: ./deployer.phar env:encrypt-key:show staging
  2. Decrypt: php artisan env:decrypt --force --env staging --key
  3. You should have the updated env file in .env.staging
  4. Update the .env.staging file as you wish
  5. Encrypt: php artisan env:encrypt --force --env staging --key
  6. Commit and push the changes

Security notes

The value of the LARAVEL_ENV_ENCRYPTION_KEY env var should be treated as a top-level secret and never be exposed on Slack, logs or other unsecure places.

Also, the unencrypted .env file should never be committed to git (it’s currently ignored by git), so make sure you’re only committing the encrypted env file.