lupennat / laravel-env-enc
encrypt/decrypt laravel .env
Installs: 93
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/lupennat/laravel-env-enc
Requires
- illuminate/console: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- illuminate/encryption: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- illuminate/support: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
This package is auto-updated.
Last update: 2025-09-09 11:31:22 UTC
README
This package allows you to Encrypt/Decrypt your .envs file in Laravel.
Install
$ composer require lupennat/laravel-env-enc
Generate a valid key
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.
Encrypt/Decrypt file .env
$ 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!
Manage multiple .env
$ 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
Hide sensitive data
add these lines in the .gitignore file
.env* !.env.*.enc
Encrypt your env files and push on your repository.