PHPackages                             helhum/dotenv-connector - 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. helhum/dotenv-connector

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

helhum/dotenv-connector
=======================

Makes it possible to set environment variables for composer projects.

v3.2.0(8mo ago)1594.6M—1.2%19[2 issues](https://github.com/helhum/dotenv-connector/issues)[2 PRs](https://github.com/helhum/dotenv-connector/pulls)20MITPHPPHP &gt;=7.4CI passing

Since Apr 21Pushed 8mo ago6 watchersCompare

[ Source](https://github.com/helhum/dotenv-connector)[ Packagist](https://packagist.org/packages/helhum/dotenv-connector)[ Docs](https://github.com/helhum/dotenv-connector)[ Fund](https://www.paypal.me/helhum/19.99)[ GitHub Sponsors](https://github.com/helhum)[ RSS](/packages/helhum-dotenv-connector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (23)Used By (20)

dotenv connector [![Build Status](https://camo.githubusercontent.com/7b0694121d1982815c31e10756a330069ac1d886364f49fac9067e587ba5b617/68747470733a2f2f7472617669732d63692e6f72672f68656c68756d2f646f74656e762d636f6e6e6563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/helhum/dotenv-connector)
=====================================================================================================================================================================================================================================================================================================================

[](#dotenv-connector-)

This is a composer plugin, that makes environment variables from a .env file available for any composer based project, without the need to modify code in the project.

Background info
---------------

[](#background-info)

You may want to read why it is a good idea to [store config in the environment](http://12factor.net/config). The idea of [dotenv](http://opensoul.org/2012/07/24/dotenv/) is to make this as easy as possible and this is why the [phpdotenv](https://github.com/vlucas/phpdotenv) library was created. phpdotenv loads environment variables from an `.env` file to getenv(), $\_ENV and $\_SERVER, but you need to add the parsing code for that yourself.

composer + symfony/dotenv + dotenv connector = &lt;3
----------------------------------------------------

[](#composer--symfonydotenv--dotenv-connector--3)

The idea of this library is, that every composer managed project, a `.env` file (in the same location as your root `composer.json`) is automatically parsed and loaded, at **composer autoload initialisation time**. This means that the environment variables are available very early, so that you can use it also during boot time of your application.

If the environment variable `APP_ENV` is set to any value, or the specified `.env` file does not exist, no operation is performed, so that you can safely require this package for production.

If you have the possibility to expose environment variables in a production environment, it is recommended to do so and also set `APP_ENV` and use the variables that are directly exposed in the environment.

However for smaller scale projects it is still a valid and easy solution to use a `.env` file also for production environments.

You can set the environment variable `DOTENV_CONNECTOR_OVERRIDE` to enable overriding of existing environment variables with the values of the `.env` file.

configuration options
---------------------

[](#configuration-options)

Usually you don't need any configuration options. However if you need to, you can adapt the path or name of the `.env` to fit your requirements.

You configure dotenv connector in the extra section of the root `composer.json` file like that:

```
  "extra": {
      "helhum/dotenv-connector": {
          "env-file": ".env",
          "adapter": "Helhum\\DotEnvConnector\\Adapter\\SymfonyDotEnv"
      }
    }
```

#### `env-file`

[](#env-file)

You can specify a relative path from the base directory, if you want to put your `.env` file a different location.

*The default value* is ".env", which means next to your root `composer.json`.

##### Side note for quoting values in the `.env` file

[](#side-note-for-quoting-values-in-the-env-file)

As the `.env` file parsing behaves like if it was included in a shell, you have to be aware of that values with literal `$` signs need to be enclosed in single quotes. This may be the case if you use hashed values of credentials you pass via `.env`, for example.

#### `adapter`

[](#adapter)

You can specify a class that implements `\Helhum\DotEnvConnector\DotEnvVars` interface, if you need a different way to expose env vars.

*The default value* is "Helhum\\DotEnvConnector\\Adapter\\SymfonyDotEnv", which uses symfony/dotenv default parsing of the one .env file.

This could be useful though e.g. if you prefer to use another dotenv parsing library to expose the variables defined in .env or you want to switch to another parsing strategy of the Symfony dotenv parsing. In the latter case use "Helhum\\DotEnvConnector\\Adapter\\SymfonyLoadEnv" as value for this option. Have a look at the existing implementations for examples.

Feedback
--------

[](#feedback)

Any feedback is appreciated. Please write bug reports, feature request, create pull requests, or just drop me a "thank you" via [Twitter](https://twitter.com/helhum) or spread the word.

Thank you!

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance60

Regular maintenance activity

Popularity60

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 84.4% 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 ~163 days

Recently: every ~357 days

Total

22

Last Release

256d ago

Major Versions

1.1.x-dev → v2.0.02017-05-30

v2.3.1 → v3.0.02020-09-01

2.x-dev → v3.0.12021-10-06

PHP version history (9 changes)v1.0.0PHP &gt;=5.3.7

v2.0.0PHP &gt;=7.0 &lt;7.2

v2.0.3PHP &gt;=7.0 &lt;7.3

v2.1.2PHP &gt;=7.0 &lt;7.4

v2.1.3PHP &gt;=7.0 &lt;7.5

v2.3.0PHP ^7.0

v3.0.0PHP ^7.2

v3.0.1PHP &gt;=7.2

v3.2.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/904370?v=4)[Helmut Hummel](/maintainers/helhum)[@helhum](https://github.com/helhum)

---

Top Contributors

[![helhum](https://avatars.githubusercontent.com/u/904370?v=4)](https://github.com/helhum "helhum (76 commits)")[![websi](https://avatars.githubusercontent.com/u/2857262?v=4)](https://github.com/websi "websi (2 commits)")[![kevin-appelt](https://avatars.githubusercontent.com/u/25666167?v=4)](https://github.com/kevin-appelt "kevin-appelt (2 commits)")[![bmack](https://avatars.githubusercontent.com/u/165630?v=4)](https://github.com/bmack "bmack (1 commits)")[![iammati](https://avatars.githubusercontent.com/u/41418763?v=4)](https://github.com/iammati "iammati (1 commits)")[![infabo](https://avatars.githubusercontent.com/u/3999104?v=4)](https://github.com/infabo "infabo (1 commits)")[![avarx](https://avatars.githubusercontent.com/u/1161946?v=4)](https://github.com/avarx "avarx (1 commits)")[![merzilla](https://avatars.githubusercontent.com/u/636309?v=4)](https://github.com/merzilla "merzilla (1 commits)")[![schliesser](https://avatars.githubusercontent.com/u/11655823?v=4)](https://github.com/schliesser "schliesser (1 commits)")[![schoeppe](https://avatars.githubusercontent.com/u/6583540?v=4)](https://github.com/schoeppe "schoeppe (1 commits)")[![simonschaufi](https://avatars.githubusercontent.com/u/941794?v=4)](https://github.com/simonschaufi "simonschaufi (1 commits)")[![SomeBdyElse](https://avatars.githubusercontent.com/u/243504?v=4)](https://github.com/SomeBdyElse "SomeBdyElse (1 commits)")[![garvinhicking](https://avatars.githubusercontent.com/u/273326?v=4)](https://github.com/garvinhicking "garvinhicking (1 commits)")

---

Tags

composerenvdotenv12factor

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/helhum-dotenv-connector/health.svg)

```
[![Health](https://phpackages.com/badges/helhum-dotenv-connector/health.svg)](https://phpackages.com/packages/helhum-dotenv-connector)
```

###  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)[ffraenz/private-composer-installer

A composer install helper for private packages

2331.7M5](/packages/ffraenz-private-composer-installer)[philippbaschke/acf-pro-installer

An install helper for Advanced Custom Fields PRO

283724.6k](/packages/philippbaschke-acf-pro-installer)[sroze/companienv

Companion for .env files

245418.8k1](/packages/sroze-companienv)[zepgram/magento-dotenv

Simple autoloader to integrate the Symfony Dotenv component into Magento2

1371.3k](/packages/zepgram-magento-dotenv)

PHPackages © 2026

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