This package allows you to Encrypt/Decrypt your .envs file in Laravel.
$ composer require lupennat/laravel-env-enc
Generate a new key based on config.app.chiper
.
$ php artisan lupennat:env-generate-key
nvK/Ay8HrB+3SAYnWSehUYajMqceBdpwvp45U3cYWd4=
Store your key outside the laravel project.
$ php artisan lupennat:env-encrypt
Provide a key:
> nvK/Ay8HrB+3SAYnWSehUYajMqceBdpwvp45U3cYWd4=
Which key cipher? [AES-256-CBC]:
[0] AES-128-CBC
[1] AES-256-CBC
> 1
File /xxx/.env.enc succesfully created!
$ php artisan lupennat:env-decrypt
Provide a key:
> nvK/Ay8HrB+3SAYnWSehUYajMqceBdpwvp45U3cYWd4=
Which key cipher? [AES-256-CBC]:
[0] AES-128-CBC
[1] AES-256-CBC
> 1
File /xxx/.env succesfully created!
$ php artisan lupennat:env-encrypt local
Provide a key:
> nvK/Ay8HrB+3SAYnWSehUYajMqceBdpwvp45U3cYWd4=
Which key cipher? [AES-256-CBC]:
[0] AES-128-CBC
[1] AES-256-CBC
> 1
File /xxx/.env.local.enc succesfully created!
$ php artisan lupennat:env-decrypt local
Provide a key:
> nvK/Ay8HrB+3SAYnWSehUYajMqceBdpwvp45U3cYWd4=
Which key cipher? [AES-256-CBC]:
[0] AES-128-CBC
[1] AES-256-CBC
> 1
File /xxx/.env.local succesfully created!
$ cp .env.local .env
$ cp .env.prod .env
$ cp .env.xxx .env
add these lines in the .gitignore file
.env*
!.env.*.enc
Encrypt your env files and push on your repository.