PHPackages                             diarmuidie/envpopulate - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. diarmuidie/envpopulate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

diarmuidie/envpopulate
======================

Tool to interactively populate a `.env` file based on an `.env.example` file whenever Composer installs or updates.

2.0.0(5y ago)1892.0k—6.3%2MITPHPPHP &gt;=7.3

Since Aug 21Pushed 5y agoCompare

[ Source](https://github.com/diarmuidie/EnvPopulate)[ Packagist](https://packagist.org/packages/diarmuidie/envpopulate)[ RSS](/packages/diarmuidie-envpopulate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (11)Used By (0)

diarmuidie/envpopulate
======================

[](#diarmuidieenvpopulate)

PHP tool to interactively populate a `.env` file based on an `.env.example` file whenever Composer installs or updates.

Based on the similar package [Incenteev/ParameterHandler](https://github.com/Incenteev/ParameterHandler). Go check that out if you need to save parameters to a YAML file instead of a env file 👍.

Developed by [Diarmuid](https://diarmuid.ie/).

[![Latest Stable Version](https://camo.githubusercontent.com/615e141ca6dc609c931be7c7accf1dab9ff190a42ffe43e8c0b772a6dd669aeb/68747470733a2f2f706f7365722e707567782e6f72672f646961726d75696469652f656e76706f70756c6174652f762f737461626c65)](https://packagist.org/packages/diarmuidie/envpopulate)[![License](https://camo.githubusercontent.com/4bf646e50af0940384d43b79466ced11445055b87abfdfee7c911bafb06309fc/68747470733a2f2f706f7365722e707567782e6f72672f646961726d75696469652f656e76706f70756c6174652f6c6963656e7365)](https://packagist.org/packages/diarmuidie/envpopulate)

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

[](#installation)

You can install EnvPopulate through [Composer](https://getcomposer.org):

```
$ composer require diarmuidie/envpopulate
```

To trigger the EnvPopulate script on composer install and updates you have to add the following scripts to your `composer.json` file:

```
{
    "scripts": {
        "post-install-cmd": [
            "Diarmuidie\\EnvPopulate\\ScriptHandler::populateEnv"
        ],
        "post-update-cmd": [
            "Diarmuidie\\EnvPopulate\\ScriptHandler::populateEnv"
        ]
    }
}
```

#### Optional

[](#optional)

If you want to change the location of the example or generated env file, or add multiple files you can also add an extra section to the `composer.json` file:

```
"extra": {
    "env-populate": {
        "files": [
            {
                "example-file": ".env.server.dist",
                "generated-file": ".env.server"
            },
            {
                "example-file": ".env.dist",
                "generated-file": ".env"
            }
        ]
    }
}
```

You can also specify if you want to not run the env populate scripts when in non-interactive mode (automated systems):

```
"extra": {
    "env-populate": {
        "run-non-interactively": false
    }
}
```

Usage
-----

[](#usage)

Make sure you have an `.env.example` file in the root of your project (or in a different location by [setting the extra options](#optional).

The script will run every time you do a `composer install` or `composer update`. Press enter to accept the default value or type to overwrite it.

See it in action:

[![asciicast](https://camo.githubusercontent.com/80ebbb6504e0389cf8599c0c3d952934c9b43715ba1dd012a916f846bb2ff08c/68747470733a2f2f61736369696e656d612e6f72672f612f37746b656173707a30777161687233313470376b686c6568682e706e67)](https://asciinema.org/a/7tkeaspz0wqahr314p7khlehh)

#### Disabling in Automated Environments

[](#disabling-in-automated-environments)

You can disable the EnvPopulate script in automated environments (CI Server like Travis or Jenkins for example). You have two options to do this:

- Run composer with `--noscripts` option. This will stop any scripts from being run (including EnvPopulate).
- Run Composer in non interactive mode (`--no-interaction`). This will cause EnvPopulate to take the default values from `.env.example`, when generating the `.env` file, without asking for user input.

Contributing
------------

[](#contributing)

Feel free to contribute features, bug fixes or just helpful advice 😄

1. Fork this repo
2. Create a feature branch
3. Submit a PR ...
4. Profit 😎

Running Tests
-------------

[](#running-tests)

You can run the tests through Docker:

```
# Build the dockerfile:
$ docker build . --tag envpopulate:latest

# Run the tests
$ docker run envpopulate:latest composer run-script test

```

Changelog
---------

[](#changelog)

See the [CHANGELOG.md](https://github.com/diarmuidie/EnvPopulate/blob/master/CHANGELOG.md) file.

Authors
-------

[](#authors)

- [Diarmuid](http://diarmuid.ie)

License
-------

[](#license)

The MIT License (MIT)

Copyright (c) 2016 Diarmuid

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% of commits — single point of failure

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 ~190 days

Recently: every ~428 days

Total

10

Last Release

1841d ago

Major Versions

1.2.1 → 2.0.02021-05-03

PHP version history (3 changes)1.0.0PHP &gt;=5.4

1.1.0PHP &gt;=5.3

2.0.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/8478c1cc380ffdafb9739f9467cd35664307ac413f8baa7fa6f690241c7528f8?d=identicon)[diarmuidie](/maintainers/diarmuidie)

---

Top Contributors

[![diarmuidie](https://avatars.githubusercontent.com/u/707037?v=4)](https://github.com/diarmuidie "diarmuidie (36 commits)")[![Avariya](https://avatars.githubusercontent.com/u/13464158?v=4)](https://github.com/Avariya "Avariya (1 commits)")

---

Tags

environmentenvdotenvparameters management

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/diarmuidie-envpopulate/health.svg)

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

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[zepgram/magento-dotenv

Simple autoloader to integrate the Symfony Dotenv component into Magento2

1371.3k](/packages/zepgram-magento-dotenv)[nystudio107/dotenvy

Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents.

326.9k](/packages/nystudio107-dotenvy)

PHPackages © 2026

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