.gitignore and .env got divorced
Did you know that Laravel v9.32.0 brought the release of two new Artisan commands:
env:encrypt
&&
env:decrypt
With these commands it is possible to securely store an encrypted copy of .env file in source control.
Firstly you need to run:
php artisan env:encrypt
The command's output displays the encryption key that was used to encrypt the file, which you should store in a secure password manager, as you will need it to decrypt the file.
After .env is encrypted, now you need to run the following command
php artisan env:decrypt --key="{generated_encryption_key}"
It's also possible to provide the key by defining an?LARAVEL_ENV_ENCRYPTION_KEY?environment variable on your server or build environment. If this environment variable is defined, the?env:decrypt?command will use its value as the decryption key.