PHPackages                             sergeyakovlev/env - 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. sergeyakovlev/env

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

sergeyakovlev/env
=================

A simple library to loads environment variables from “.env” file

1.0.0(4y ago)049MITPHPPHP ^8.0

Since Feb 16Pushed 1w ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

Env
===

[](#env)

A simple library to loads environment variables from “.env” file.

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

[](#installation)

Install via [Composer](https://getcomposer.org/):

```
$ composer require sergeyakovlev/env
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

```
use SergeYakovlev\Env\Env;

// If necessary non-default initialization
Env::init('/path/to/project', ['.env.dist', '.env']); // This is the default behavior
```

### Use cases

[](#use-cases)

```
// The first use case
$dbHostname = Env::var('DB_HOSTNAME');

// The second use case is with the default value
$dbHostname = Env::var('DB_HOSTNAME', 'localhost');

// Check if an environment variable is existed
$dbHostnameIsExists = Env::exists('DB_HOSTNAME');
```

### Example of “.env” file

[](#example-of-env-file)

```
# Comment Line

STRING_VAR1=StringValueWithoutSpaces
STRING_VAR2="String value with spaces"

BOOLEAN_VAR1=true
BOOLEAN_VAR2=false

BOOLEAN_VAR3=on
BOOLEAN_VAR4=off

INT_VAR=123

FLOAT_VAR=123.45
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance64

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1552d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/750c80b87297ae684525a6cb6e3296c08509673f3b1911122c00a6f7757dfa58?d=identicon)[sergeyakovlev](/maintainers/sergeyakovlev)

---

Top Contributors

[![sergeyakovlev](https://avatars.githubusercontent.com/u/7995774?v=4)](https://github.com/sergeyakovlev "sergeyakovlev (2 commits)")

---

Tags

configdotenvenvenvironmentphpphpconfigenvironmentenvdotenv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sergeyakovlev-env/health.svg)

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

###  Alternatives

[vlucas/phpdotenv

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

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[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)
