15
FebHow many times have you onboarded a new dev onto your team, only to have to spend ages debugging with them because your project’s .env.example
file is wildly outdated? Too many to count, if you’re anything like us. Wouldn’t it be nice if there were a way to ensure your environment files stay up to date? That’s why we created Envy!
Envy is a package by Worksome, which helps you to keep your environment files up to date.
With a simple Artisan command, you can sync your environment files with your project config to keep everything fresh.
You can install the package via composer:
composer require worksome/envy --dev
We recommend publishing our config file, which allows you to fine-tune Envy to your project’s requirements. You can do that using our install
command:
php artisan envy:install
That’s it! You’re now ready to start using Envy.
Envy provides two commands: envy:sync
and envy:prune
. Let’s break down how to use each of them.
php artisan envy:sync
This command combs through your project’s config
files for calls to Laravel’s env function. After finding them all, it will compare them against your configured environment files (by default just your .env.example
) for missing entries. If there are missing entries, you will be given the choice to either:
To learn more about configuring environment files, config
files, and exclusions, see the Configuration documentation.
The envy:sync
command provides several options you might find helpful.
–path
If you’d like to run the sync command against a certain environment file, rather than your configured environment files, you may pass the path to the specified environment file using this option.
–dry
The –dry
option will prevent the command from actually performing any updates. This is useful if you want to run Envy as part of a CI check without actually making updates. If missing entries were found, the command will fail, which would in turn fail the check-in CI.
–force
If you want to automatically make changes to your configured environment files without being asked to confirm, you may pass the –force
option. This is useful for CI bots, where you want to automate changes to your .env.example
file, as no user input will be requested.
php artisan envy:prune
This command will search your project’s configured environment files (by default just your .env.example
) for entries that could not be found in any of the configured config files. If there are additional entries, you will be given the choice to either:
To learn more about configuring environment files, config files, and inclusions, see the Configuration documentation.
The envy:prune
command provides several options you might find helpful.
–path
If you’d like to run the prune command against a certain environment file, rather than your configured environment files, you may pass the path to the specified environment file using this option.
–dry
The –dry
option will prevent the command from actually pruning any environment variables. This is useful if you want to run Envy as part of a CI check without actually making updates. If additional entries were found, the command will fail, which would in turn fail the check-in CI.
–force
If you want to automatically make changes to your configured environment files without being asked to confirm, you may pass the –force
option. This is useful for CI bots, where you want to automate changes to your .env.example
file, as no user input will be requested.
You can customize Envy to suit your project’s requirements using our envy.php
config file. This package has a lot of configuration options with code examples. If you want to dig more, you can visit its complete documentation and source code on Github
Published at : 15-02-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project