Encrypt environment files with Padlock

Packages

February 14th, 2023

Encrypt environment files with Padlock

Padlock is a Laravel Zero command by Daniel Mason for encrypting and decrypting environment files powered by Laravel's encryption commands. Since it's installed globally via composer, you can use it to encrypt files in the current working directory for any project:

$ padlock env:encrypt --env=testing
 
INFO Environment successfully encrypted.
 
Key ................ base64:RR480kEd+Yen6cCMkXmmGUz38cJYwlP/qNctQ7MA6zo=
Cipher ............. AES-256-CBC
Encrypted file ..... .env.testing.encrypted

And here's an example command for decrypting the above-encrypted environment file:

$ padlock env:decrypt --env=testing --key=base64:RR480kEd+Yen6cCMkXmmGUz38cJYwlP/qNctQ7MA6zo=
 
INFO Environment successfully decrypted.
 
Decrypted file ..... .env.testing

What is neat about this package is that it's globally available but uses the Laravel framework commands under the hood to power the encryption/decryption operation. That means you could use this CLI to encrypt non-Laravel and non-PHP envrionment files.

You can get started with this CLI by installing it globally on your machine:

$ composer global require fidum/padlock

Since this CLI uses Laravel's artisan commands, see the Encrypting environment files documentation for further details.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.