{"id":13620343,"url":"https://github.com/worksome/envy","last_synced_at":"2025-05-14T03:10:58.494Z","repository":{"id":37534692,"uuid":"453952491","full_name":"worksome/envy","owner":"worksome","description":"Keep your .env.example file up to date","archived":false,"fork":false,"pushed_at":"2025-03-04T17:48:34.000Z","size":184,"stargazers_count":680,"open_issues_count":2,"forks_count":30,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-12T01:17:02.482Z","etag":null,"topics":["console","environment","laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/worksome.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"worksome"}},"created_at":"2022-01-31T09:54:55.000Z","updated_at":"2025-05-07T15:40:23.000Z","dependencies_parsed_at":"2024-11-08T06:32:48.417Z","dependency_job_id":"132056f6-21b3-4520-aee5-da68166be601","html_url":"https://github.com/worksome/envy","commit_stats":{"total_commits":38,"total_committers":8,"mean_commits":4.75,"dds":0.2894736842105263,"last_synced_commit":"640b465e6921c884bc4309048728c5219d23f41e"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":"worksome/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worksome%2Fenvy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worksome%2Fenvy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worksome%2Fenvy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worksome%2Fenvy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/worksome","download_url":"https://codeload.github.com/worksome/envy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059513,"owners_count":22007769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["console","environment","laravel"],"created_at":"2024-08-01T21:00:54.714Z","updated_at":"2025-05-14T03:10:53.471Z","avatar_url":"https://github.com/worksome.png","language":"PHP","funding_links":["https://github.com/sponsors/worksome"],"categories":["PHP","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Envy\n\nAutomate keeping your environment files in sync.\n\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/worksome/envy/run-tests.yml?branch=main)](https://github.com/worksome/envy/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![PHPStan](https://github.com/worksome/envy/actions/workflows/phpstan.yml/badge.svg)](https://github.com/worksome/envy/actions/workflows/phpstan.yml)\n\nHow 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!\n\n**With a simple Artisan command, you can sync your environment files with your project config to keep everything fresh.**\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require worksome/envy --dev\n```\n\nWe 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:\n\n```bash\nphp artisan envy:install\n```\n\nThat's it! You're now ready to start using Envy.\n\n## Usage\n\nEnvy provides two commands: `envy:sync` and `envy:prune`. Let's break down how to use each of them.\n\n### `php artisan envy:sync`\n\n\u003cimg width=\"653\" alt=\"CleanShot 2022-02-01 at 16 18 27@2x\" src=\"https://user-images.githubusercontent.com/12202279/152007083-604c3609-2aef-4bae-b053-e26a4b009fc8.png\"\u003e\n\nThis 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:\n1. Add the missing keys to your environment file\n2. Add the missing keys to Envy's exclusion list\n\nTo learn more about configuring environment files, config files and exclusions, see the Configuration documentation.\n\nThe `envy:sync` command provides several options you might find helpful.\n\n#### `--path`\n\nIf 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.\n\n#### `--dry`\n\nThe `--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.\n\n#### `--force`\n\nIf 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.\n\n### `php artisan envy:prune`\n\n\u003cimg width=\"580\" alt=\"CleanShot 2022-02-02 at 12 03 51@2x\" src=\"https://user-images.githubusercontent.com/12202279/152150299-59909889-8e18-4c19-9387-7f8d11019847.png\"\u003e\n\nThis 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:\n1. Remove the additional entries from your environment file\n2. Add the missing keys to Envy's inclusion list\n\nTo learn more about configuring environment files, config files and inclusions, see the Configuration documentation.\n\nThe `envy:prune` command provides several options you might find helpful.\n\n#### `--path`\n\nIf 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.\n\n#### `--dry`\n\nThe `--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.\n\n#### `--force`\n\nIf 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.\n\n## Configuration\n\nYou can customise Envy to suit your project's requirements using our `envy.php` config file. Here is a breakdown of the available options.\n\n### `environment_files`\n\nOut 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.\n\n\u003e ⚠️ We do not recommend adding your `.env` file to this array as it could cause unwanted side effects, particularly in CI.\n\n### `config_files`\n\nBy 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.\n\nThis 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.\n\nNote that if you reference a directory instead of a file, it will include all files in that directory recursively.\n\n### `display_comments`\n\n\u003cimg width=\"867\" alt=\"CleanShot 2022-02-01 at 16 28 42@2x\" src=\"https://user-images.githubusercontent.com/12202279/152009032-093cb464-9e69-4fdc-9869-291907b7b001.png\"\u003e\n\nSome 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.\n\n### `display_location_hints`\n\nWhen 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.\n\n### `display_default_values`\n\nWhen 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.\n\nFor obvious reasons, we will only insert scalar (primitive) types when copying default values. \n\n\u003e ⚠️ 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.\n\n### `exclude_calls_with_defaults`\n\nIf 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.\n\n### `exclusions`\n\nThis 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.\n\nIf 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.\n\n\u003e 💡 You may still manually insert keys from your exclusions into your `.env` file. We won't remove them.\n\n### `inclusions`\n\nThis 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.\n\nIf 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.\n\n## Advanced\n\nOnce you're familiar with the basics of Envy, you may find these advanced features useful.\n\n### Filters\n\nSometimes, 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 \nexclusions list. Rather than manually inserting them all individually, you can use the `Worksome\\Envy\\Support\\Filters\\Filter` class.\n\n```php\n/**\n * Any environment variables that are added to exclusions will never be inserted\n * into .env files. Our defaults are based on the base Laravel config files.\n * Feel free to add or remove variables as required by your project needs.\n */\n'exclusions' =\u003e [\n    Filter::wildcard('STRIPE_*'),\n],\n```\n\nNow, 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 \nfilter 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\nthe `Worksome\\Envy\\Contracts\\Filter` contract, so you can even implement your own filters if that's your style.\n\n## Testing\n\nWe pride ourselves on a thorough test suite and strict static analysis. You can run all of our checks via a composer script:\n\n```bash\ncomposer test\n```\n\nTo make it incredibly easy to contribute, we also provide a docker-compose file that will spin up a container\nwith all the necessary dependencies installed. Assuming you have docker installed, just run:\n\n```bash\ndocker-compose run --rm composer install # Only needed the first time\ndocker-compose run --rm composer test # Run tests and static analysis \n```\n\nSupport for XDebug is baked into the Docker image, you just need to configure the `XDEBUG_MODE` environment variable:\n\n```bash\ndocker-compose run --rm -e XDEBUG_MODE=debug php\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Credits\n\n- [Luke Downing](https://github.com/lukeraymonddowning)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworksome%2Fenvy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworksome%2Fenvy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworksome%2Fenvy/lists"}