PHPackages                             worksome/envy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. worksome/envy

ActiveLibrary[CLI &amp; Console](/categories/cli)

worksome/envy
=============

Automatically keep your .env files in sync.

v1.5.0(2mo ago)6871.8M↓15.5%31[4 PRs](https://github.com/worksome/envy/pulls)MITPHPPHP ^8.4CI passing

Since Feb 2Pushed 2mo ago15 watchersCompare

[ Source](https://github.com/worksome/envy)[ Packagist](https://packagist.org/packages/worksome/envy)[ Docs](https://github.com/worksome/envsync)[ GitHub Sponsors](https://github.com/worksome)[ RSS](/packages/worksome-envy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (22)Versions (24)Used By (0)

Envy
====

[](#envy)

Automate keeping your environment files in sync.

[![Latest Version on Packagist](https://camo.githubusercontent.com/dac2d6f75f7b3904b013b379119f8f8212c4dd84ff16c760298c0e500d910256/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f726b736f6d652f656e76792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/worksome/envy)[![GitHub Tests Action Status](https://camo.githubusercontent.com/462513711997aaff8f77621826fa7b00557bff1d7cdfd44c5306844177c92160/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f656e76792f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d5465737473)](https://github.com/worksome/envy/actions?query=workflow%3ATests+branch%3Amain)[![GitHub Static Analysis Action Status](https://camo.githubusercontent.com/fba1e4dd29c610b57fa96243e2b6306ef8035a7ccd57a9b85d54995f34192a18/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f776f726b736f6d652f656e76792f7374617469632e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d537461746963253230416e616c79736973)](https://github.com/worksome/envy/actions?query=workflow%3A%22Static%20Analysis%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7341e52ab4c61ca142614df7f55fa322017a6aa8defc38cbee83d97e8f0f08de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f726b736f6d652f656e76792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/worksome/envy)

How 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!

**With a simple Artisan command, you can sync your environment files with your project config to keep everything fresh.**

Installation
------------

[](#installation)

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.

Usage
-----

[](#usage)

Envy provides two commands: `envy:sync` and `envy:prune`. Let's break down how to use each of them.

### `php artisan envy:sync`

[](#php-artisan-envysync)

[![CleanShot 2022-02-01 at 16 18 27@2x](https://user-images.githubusercontent.com/12202279/152007083-604c3609-2aef-4bae-b053-e26a4b009fc8.png)](https://user-images.githubusercontent.com/12202279/152007083-604c3609-2aef-4bae-b053-e26a4b009fc8.png)

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:

1. Add the missing keys to your environment file
2. Add the missing keys to Envy's exclusion list

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`

[](#--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`

[](#--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`

[](#--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`

[](#php-artisan-envyprune)

[![CleanShot 2022-02-02 at 12 03 51@2x](https://user-images.githubusercontent.com/12202279/152150299-59909889-8e18-4c19-9387-7f8d11019847.png)](https://user-images.githubusercontent.com/12202279/152150299-59909889-8e18-4c19-9387-7f8d11019847.png)

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:

1. Remove the additional entries from your environment file
2. Add the missing keys to Envy's inclusion list

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`

[](#--path-1)

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`

[](#--dry-1)

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`

[](#--force-1)

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.

CI recipes (GitHub Actions)
---------------------------

[](#ci-recipes-github-actions)

You can fail CI when your `.env.example` is out of sync by running Envy in dry mode:

```
name: Envy Check

on:
  pull_request:
  push:
    branches: [ main ]

jobs:
  envy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.4'
          coverage: none
      - run: composer install --no-interaction --no-progress
      - run: php artisan envy:sync --dry
      - run: php artisan envy:prune --dry
```

Configuration
-------------

[](#configuration)

You can customise Envy to suit your project's requirements using our `envy.php` config file. Here is a breakdown of the available options.

### `environment_files`

[](#environment_files)

Out of the box, Envy will only make changes to your `.env.example` file. If you want to add additional `.env` files, such as `.env.testing` or `.env.dusk`, you can append them to this array.

> ⚠️ We do not recommend adding your `.env` file to this array as it could cause unwanted side effects, particularly in CI.

### `config_files`

[](#config_files)

By default, Envy will recursively scan all files in your project's `config` directory. For most projects, this will suffice. If your project makes `env` calls *outside* of config files (which is an anti-pattern), you should add the relevant files or directories to this array.

This is also useful if you make use of a package for which you have *not* published its config file. You may instead add an entry to this array that points to the base config file in the `vendor` directory.

Note that if you reference a directory instead of a file, it will include all files in that directory recursively.

### `display_comments`

[](#display_comments)

[![CleanShot 2022-02-01 at 16 28 42@2x](https://user-images.githubusercontent.com/12202279/152009032-093cb464-9e69-4fdc-9869-291907b7b001.png)](https://user-images.githubusercontent.com/12202279/152009032-093cb464-9e69-4fdc-9869-291907b7b001.png)

Some config keys, such as the one pictured above, may include comments. If you set `display_comments` to `true`, we will convert the config comment to an environment comment and place it above the relevant environment variable when inserting it into your configured environment files. This can be helpful in certain projects for remembering the purpose of various environment variables.

### `display_location_hints`

[](#display_location_hints)

When combing your config files, we make a note of the file and line where you called `env`. If you set `display_location_hints` to `true`, we will create a comment with this location information and place it above the relevant environment variable when inserting it into your configured environment files. This can be helpful in certain projects for locating the usage of various environment variables.

### `display_default_values`

[](#display_default_values)

When combing your config files, we make a note of any default parameter set in the `env` call. For example, given a call for `env('APP_NAME', 'Laravel')`, the default would be `'Laravel'`. If `display_default_values` is set to `true`, we will insert the default value as the value for the relevant environment variable when updating your configured environment files.

For obvious reasons, we will only insert scalar (primitive) types when copying default values.

> ⚠️ If you have `exclude_calls_with_defaults` set to `true` (which is the default), this option will have no effect because calls with defaults will be ignored.

### `exclude_calls_with_defaults`

[](#exclude_calls_with_defaults)

If you copy over every single call to `env`, your environment files will quickly become difficult to read. To help alleviate this, we provide the option to ignore calls to `env` that have default values provided. By default this is enabled, but setting this to `false` will let Envy sync environment variables that have defaults too.

### `exclusions`

[](#exclusions)

This array is a collection of environment keys that should never be synced to your environment files. By default, we include all Laravel environment variables that aren't included in the default `.env` file created when you first create a new Laravel project. Removing values from this array will cause them to be picked up again whilst syncing. Of course, if you have custom variables or variables provided by packages that you want to ignore, you may add them here.

If you select the `Add to exclusions` option when running `php artisan envy:sync`, this array will be updated with the environment variables listed by that command.

> 💡 You may still manually insert keys from your exclusions into your `.env` file. We won't remove them.

### `inclusions`

[](#inclusions)

This array is a collection of environment keys that we should never prune from your configured environment files, even if we cannot find reference to those variables in your configured config files. This can be useful for JS variables used by Laravel Mix, for example.

If you select the `Add to inclusions` option when running `php artisan envy:prune`, this array will be updated with the environment variables listed by that command.

Advanced
--------

[](#advanced)

Once you're familiar with the basics of Envy, you may find these advanced features useful.

### Filters

[](#filters)

Sometimes, you'll want a more powerful way to represent items in the `exclusions` and `inclusions` lists than basic strings. For example, imagine you want to add all environment variables beginning with `STRIPE_` to the exclusions list. Rather than manually inserting them all individually, you can use the `Worksome\Envy\Support\Filters\Filter` class.

```
/**
 * Any environment variables that are added to exclusions will never be inserted
 * into .env files. Our defaults are based on the base Laravel config files.
 * Feel free to add or remove variables as required by your project needs.
 */
'exclusions' => [
    Filter::wildcard('STRIPE_*'),
],
```

Now, any environment variable starting with `STRIPE_` will automatically be excluded when syncing to your configured environment files. We also offer `Filter::regex`, which is an even more powerful filter that allows you to match environment variables against regular expression you provide. In fact, the `exclusions` and `inclusions` lists will accept a `string` or *any* class which implements the `Worksome\Envy\Contracts\Filter` contract, so you can even implement your own filters if that's your style.

Testing
-------

[](#testing)

We pride ourselves on a thorough test suite and strict static analysis. You can run all of our checks via a composer script:

```
composer test
```

To make it incredibly easy to contribute, we also provide a docker-compose file that will spin up a container with all the necessary dependencies installed. Assuming you have docker installed, just run:

```
docker-compose run --rm composer install # Only needed the first time
docker-compose run --rm composer test # Run tests and static analysis
```

Support for XDebug is baked into the Docker image, you just need to configure the `XDEBUG_MODE` environment variable:

```
docker-compose run --rm -e XDEBUG_MODE=debug php
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Luke Downing](https://github.com/lukeraymonddowning)
- [Owen Voke](https://github.com/owenvoke)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity62

Solid adoption and visibility

Community25

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~188 days

Total

15

Last Release

77d ago

Major Versions

v0.5.0 → v1.0.02023-02-01

PHP version history (3 changes)v0.1.0PHP ^8.0|^8.1

v1.0.0PHP ^8.2

v1.5.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/139db346fa173a79481af05b0455e2e8ad7d2ab594c7f53bde3522a3dfeeaf25?d=identicon)[96downlu](/maintainers/96downlu)

---

Top Contributors

[![lukeraymonddowning](https://avatars.githubusercontent.com/u/12202279?v=4)](https://github.com/lukeraymonddowning "lukeraymonddowning (42 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (31 commits)")[![ishifoev](https://avatars.githubusercontent.com/u/34019391?v=4)](https://github.com/ishifoev "ishifoev (4 commits)")[![xiCO2k](https://avatars.githubusercontent.com/u/823088?v=4)](https://github.com/xiCO2k "xiCO2k (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![olivernybroe](https://avatars.githubusercontent.com/u/5870441?v=4)](https://github.com/olivernybroe "olivernybroe (2 commits)")[![skylerkatz](https://avatars.githubusercontent.com/u/7297992?v=4)](https://github.com/skylerkatz "skylerkatz (2 commits)")[![ziming](https://avatars.githubusercontent.com/u/679513?v=4)](https://github.com/ziming "ziming (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![kayw-geek](https://avatars.githubusercontent.com/u/29700073?v=4)](https://github.com/kayw-geek "kayw-geek (1 commits)")[![mdavis1982](https://avatars.githubusercontent.com/u/199807?v=4)](https://github.com/mdavis1982 "mdavis1982 (1 commits)")[![a-bashtannik](https://avatars.githubusercontent.com/u/2712350?v=4)](https://github.com/a-bashtannik "a-bashtannik (1 commits)")

---

Tags

consoleenvironmentlaravellaravelworksomeenvsync

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/worksome-envy/health.svg)

```
[![Health](https://phpackages.com/badges/worksome-envy/health.svg)](https://phpackages.com/packages/worksome-envy)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k7.8M57](/packages/dedoc-scramble)[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[worksome/verify-by-phone

Verify your users by call or SMS

148550.4k](/packages/worksome-verify-by-phone)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
