PHPackages                             ez-php/dotenv - 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. ez-php/dotenv

ActiveLibrary

ez-php/dotenv
=============

Lightweight .env file loader for PHP — supports quoted values, variable interpolation, and immutable loading

1.0.1(1mo ago)01.4k↑310.1%1MITPHPPHP ^8.5CI passing

Since Mar 14Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/dotenv)[ Packagist](https://packagist.org/packages/ez-php/dotenv)[ Docs](https://github.com/ez-php/dotenv)[ RSS](/packages/ez-php-dotenv/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (22)Used By (1)

ez-php/dotenv
=============

[](#ez-phpdotenv)

Lightweight `.env` file loader for PHP — supports quoted values, variable interpolation, and immutable loading. Zero dependencies.

[![CI](https://github.com/ez-php/dotenv/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/dotenv/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/c999b3158afdad9bab35cab2f5e3e34e513bc1b013514a273462ac2867bb05f6/68747470733a2f2f636f6465636f762e696f2f67682f657a2d7068702f646f74656e762f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/ez-php/dotenv)

Requirements
------------

[](#requirements)

- PHP 8.5+

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

[](#installation)

```
composer require ez-php/dotenv
```

Usage
-----

[](#usage)

```
use EzPhp\Env\Dotenv;

// Load .env from the project root (immutable — never overwrites existing env vars)
Dotenv::createImmutable(__DIR__)->load();

// Silently skip if the file doesn't exist (useful in production)
Dotenv::createImmutable(__DIR__)->safeLoad();

// Custom filename
Dotenv::createImmutable(__DIR__, '.env.testing')->load();
```

Variables are written to `$_ENV`, `$_SERVER`, and `getenv()`.

Supported syntax
----------------

[](#supported-syntax)

```
# Comments are ignored
APP_NAME=My App
APP_ENV=production

# Quoted values preserve whitespace and support escapes
GREETING="Hello, World!\nWelcome."

# Single-quoted values are literal — no interpolation, no escapes
LITERAL='value with $dollar and \n backslash'

# Variable interpolation in double-quoted values
BASE_URL=https://example.com
API_URL="${BASE_URL}/api/v1"

# export prefix is stripped
export SECRET_KEY=abc123

# Empty values
EMPTY=
```

Immutability
------------

[](#immutability)

Variables already present in the environment (set before loading) are never overwritten. This means real environment variables (e.g. set in Docker or CI) always take precedence over `.env` file values.

License
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance91

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~0 days

Total

21

Last Release

46d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/a15a63c46d239d42b8ed4c2fe9adbc5fe99eb62f6e5bb90f08021e0c068e8b37?d=identicon)[AU9500](/maintainers/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (74 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

phpconfigenvironmentenvdotenv

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-dotenv/health.svg)

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

###  Alternatives

[vlucas/phpdotenv

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

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

PHPackages © 2026

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