
Keep Laravel .env Synced With Envy
Envy is a package to keep your .env.example file up to date automatically:
IMYMI, yesterday we released a brand new #Laravel package called Envy ?
Its purpose is to scan your project and keep track of missing or outdated environment variables based on your config files ?https://t.co/730aLIP9Wc
— Luke Downing (@LukeDowning19) February 10, 2022
This package works by scanning your project config files for calls to Laravel’s env()
function and comparing them against your configured environment files (i.e., .env.example). The package will then prompt you to either add them to the environment file or exclude them:
[image:F88EB794-28CD-4A12-AEEF-8C687761588D-6640-000208C00A66E2BF/3F169248-E57E-4144-BDC6-7AE848C901F5.png]
You can also prune environment files using the envy:prune
command, which will compare the .env.example
file against actual config and remove values in the environment file no longer in use.
Not only is this package easy to use out of the box, the configuration files include options such as copying the comments from the PHP config over to the .env.example file above the value as a valid DotEnv comment. You can also configure advanced exclusions using the Filter
class provided by the package:
1// config/envy.php
2use WorksomeEnvySupportFiltersFilter;
3
4return [
5 // ...
6 'exclusions' => [
7 Filter::wildcard('STRIPE_*'),
8 ]
9];
The source code and documentation are available on GitHub at worksome/envy. You can get started with this package by installing it via composer:
1composer require worksome/envy --dev
2php artisan envy:install
Credit: Source link