Open-source project
symfony/dotenv avatar
symfony/dotenv

symfony/dotenv's default branch is 8.2 and its newest release is v8.1.6, published the same day

Registers environment variables from a .env file

3,789 stars28 forksPHPMIT

At a glance

What is it?
symfony/dotenv is one PHP class that parses a .env file into $_ENV or $_SERVER, plus an exception directory, a console command and a PHPUnit suite. Sixty-eight words of documentation cover all of it, and the one behaviour it does not describe is which file wins when you load several.
Who is it for?
The component fits a Symfony application that wants a .env file parsed at boot with the conventional cascade of local and environment-specific overrides, and it is small enough to read in one sitting. It does not fit a project that needs to know the precedence between two files it passes to load(), because the page does not say.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 11 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • symfony/dotenv3,789 ★ · -1
Star history
Repository2026-09-242026-11-15
symfony/dotenv3.8k3.8k

-1 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Three releases in twenty-one minutes, and the default branch is ahead of all of them

The three most recent releases share one timestamp day and one owner. v8.1.6 was published at 21:44:00 on 2026-08-30, v7.4.18 at 21:39:46 the same evening, and v6.4.45 at 21:23:26.

So three maintenance lines were cut inside twenty-one minutes: the 8.1 line, the 7.4 line and the 6.4 line. That is the shape of a component with several supported Symfony versions rather than a single one, and it is why the package is not versioned on its own scheme.

The default branch is 8.2. The newest tag is v8.1.6. So the branch a clone gives you is the next minor version ahead of anything published, which is the right thing for a contributor and the wrong thing for someone who clones expecting the newest release. Nothing on the page points that out.

Four methods on one object, and three descriptions to go with them

The whole usage section is one block. Four calls on the same object:

php
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');

// you can also load several files
$dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev');

// overwrites existing env variables
$dotenv->overload(__DIR__.'/.env');

// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
$dotenv->loadEnv(__DIR__.'/.env');

Three of the four carry a comment. The fourth, the plain load of one file, needs none. The comment on the two-argument form says only that you can load several files, and stops there.

So the surface is: load one file, load several, load and overwrite what is already set, and load with the cascade. What is missing is the rule that decides the outcome when two of the loaded files define the same variable, which is the only question a reader of that second call would actually have.

loadEnv resolves four filenames in one sentence

The cascade is written as a single comment: it loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV.

That is four candidate filenames and one disjunction. The order they are written in implies that the plain file is read first and the environment-specific one last, and that the local variant is preferred over its non-local counterpart, since it is listed first in the pair. None of that is stated as a rule; it is inferred from the order of words in a comment.

It also settles the shape of a Symfony environment without saying so: the value of $APP_ENV has to be readable before this call, which means something else has to have set it. The page does not explain how, and for a component whose job is populating the environment that is the interesting missing step.

Values end up in two superglobals and the page does not choose between them

The description says the parsed variables are made accessible via $_SERVER or $_ENV. The usage block reads them both ways, once as:

php
// Usage with $_ENV
$envVariable = $_ENV['YOUR_VARIABLE_NAME'];

and once with the same key against $_SERVER.

Which of the two arrays the component populates, and whether it populates one or both, is not stated. The two are populated by different PHP configuration settings, so a caller whose php.ini sets one but not the other gets a different result from the same four lines of code. That is the kind of detail this page does not mention, and it is the kind a caller finds out about at run time.

The tree has a Command directory and an Exception directory the page never mentions

The repository is small and mostly visible from the usage block. Dotenv.php at the root is the component itself. Exception/ is where the exception types live, and Tests/ with phpunit.xml.dist is the test suite. composer.json and CHANGELOG.md are ordinary.

Command/ is the one that the page does not account for. A console command in a Symfony component is a separate entry point with its own arguments and output format, and none of it appears in the usage section, which shows only the object API. A reader who installs this into a Symfony application may find a command available that the documentation never mentions.

There is also no .github/ directory in the tree, which follows from where contributions go.

Issues and pull requests both go to the monorepo

The resources section has three links: the contributing guide, and then issues and pull requests, both pointed at the main Symfony repository rather than at this one.

That is the split-repository arrangement, and it means this repository is a staging area rather than a place to file. It also means the CHANGELOG.md at the root is not where a change to it would be proposed, and that the version branch structure is decided elsewhere.

The page does not explain the arrangement. A first-time contributor gets two repositories named in one line and no reason for it, which is a small thing that costs the same half hour every time someone new arrives.

The sponsor block jumps from a reference one to a reference three

The last content section asks for a backer and links two pages. The link labels are numbered, and the numbers are 1 and 3.

There is no reference 2 in the document. The two link definitions at the bottom are the backers page and the sponsor page, so the numbering came from somewhere else, probably a shared template used across components that has since dropped its second link.

It is a trivial defect and it is the only thing in the repository that suggests the page was assembled from a family of identical files rather than written for this component. Everything else in the sixty-eight words is either about behaviour or about where to send a patch.

Editorial conclusion

The component fits a Symfony application that wants a .env file parsed at boot with the conventional cascade of local and environment-specific overrides, and it is small enough to read in one sitting. It does not fit a project that needs to know the precedence between two files it passes to load(), because the page does not say. Check three things before you adopt it. Which method you actually want, since overload() and loadEnv() differ from load() in ways the comments only hint at. Where your issue goes, which is the monorepo rather than this repository. And which branch you are on, because the default branch is ahead of every published tag.

Frequently asked questions

What does symfony/dotenv do?

It parses .env files and makes the variables in them accessible through $_SERVER or $_ENV. You construct a Dotenv instance, point it at the file with load(), and then read the values from those superglobals.

How do I load more than one .env file with symfony/dotenv?

load() takes several paths at once, for example $dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev'). The page does not state which file wins when two of them define the same variable.

What is the difference between load and overload in symfony/dotenv?

load() populates the variables from the file, and overload() overwrites environment variables that are already set. A third method, loadEnv(), loads .env, then .env.local, then .env.$APP_ENV.local or .env.$APP_ENV.

Where should I file an issue for symfony/dotenv?

In the main Symfony repository. The page points both the issue tracker and the pull requests at github.com/symfony/symfony, and this repository's tree has no .github/ directory of its own.

Which PHP or Symfony versions does symfony/dotenv target?

The page states no version requirement at all. What the repository records is its branching: the default branch is 8.2, while the three most recent releases are v8.1.6, v7.4.18 and v6.4.45, all published on 2026-08-30.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. symfony/dotenv on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/symfony-dotenv.svg)](https://hysenlabs.com/projects/symfony-dotenv)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/symfony-dotenv.svg)](https://hysenlabs.com/projects/symfony-dotenv)

Was this useful?