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

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

climbx/dotenv
=============

.env files manager

1.0.5(4y ago)06MITPHPPHP &gt;=8.0

Since Jun 10Pushed 4y agoCompare

[ Source](https://github.com/climbx/Dotenv)[ Packagist](https://packagist.org/packages/climbx/dotenv)[ RSS](/packages/climbx-dotenv/feed)WikiDiscussions 1.0 Synced 1w ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Dotenv
======

[](#dotenv)

[![Build Status](https://camo.githubusercontent.com/74c7e4f1ce29aade6917cee6ac23ecd39f2c7c2015d151095f49f1757e06d346/68747470733a2f2f7472617669732d63692e636f6d2f636c696d62782f446f74656e762e7376673f6272616e63683d312e30)](https://travis-ci.com/climbx/Dotenv)[![Maintainability](https://camo.githubusercontent.com/e295706ba5a31e32938c0b421611041d92f108f8f827694a3355d7767d1657a3/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39356438383464303438653931303836646637642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/climbx/Dotenv/maintainability)[![Test Coverage](https://camo.githubusercontent.com/ebe896a955590873d3800be970b9d21ba5e2db18bad01ce70835dc5bbd10d188/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39356438383464303438653931303836646637642f746573745f636f766572616765)](https://codeclimate.com/github/climbx/Dotenv/test_coverage)

Dotenv component parses `.env` files and add them to both `$_ENV` and `$_SERVER`.

Install
-------

[](#install)

```
$ composer require climbx/dotenv

```

Usage
-----

[](#usage)

```
# .env

foo=bar
bar=baz
```

```
// PHP

use Climbx\Dotenv\Dotenv;

$dotenv = new Dotenv();
$envPath = __DIR__ . '/.env';

/*
 * Loads env vars into $_ENV and $_SERVER
 * without overwriting existing variables
 */
$dotenv->load($envPath);

/*
 * Loads env vars into $_ENV and $_SERVER
 * if a variable already exists, it is overridden.
 */
$dotenv->overload($envPath);
```

Env files syntax
----------------

[](#env-files-syntax)

```
# Comment line

foo=bar                                 # End line comment
bar='this is a single quotted value'    # allows whitespaces
baz="this is a double quotted value"
num=1234
```

Variables references
--------------------

[](#variables-references)

Simple var reference:

```
foo=bar
baz=$foo        # outputs ['baz' => 'bar']
```

Multiple var references:

```
foo=1
bar=2

spaced="$foo and $bar"   # outputs ['spaced' => '1 and 2']
collapsed=$one$two       # outputs ['collapsed' => '12']
```

Partial var references:

```
foo="one"
bar="two"

baz=${foo}/${bar}/three      # outputs ['baz' => 'one/two/three']
```

Escaped var declaration char

```
foo=bar
echaped1=\$foo   # outputs ['echaped1' => '$foo']
echaped2=\${foo} # outputs ['echaped2' => '${foo}']
```

Missing var reference.
Missing references don't throw an exception. If a reference is not found, the value is set to an empty string.

```
missing1=$foo     # outputs ['missing1' => '']
missing2=${foo}  # outputs ['missing2' => '']
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

5

Last Release

1801d ago

### Community

Maintainers

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

---

Top Contributors

[![pierregaimard](https://avatars.githubusercontent.com/u/50302445?v=4)](https://github.com/pierregaimard "pierregaimard (70 commits)")

---

Tags

phpenv

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[allysonsilva/laravel-multienv

This package allows you to use multiple .envs in multitenant environment

537.2k](/packages/allysonsilva-laravel-multienv)

PHPackages © 2026

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