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

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

lirien/env
==========

A minimal and straightforward .env file loader for PHP

1.0.1(5mo ago)21[1 issues](https://github.com/claudiovictors/lirien-env/issues)MITPHPPHP ^8.1

Since Dec 9Pushed 5mo agoCompare

[ Source](https://github.com/claudiovictors/lirien-env)[ Packagist](https://packagist.org/packages/lirien/env)[ RSS](/packages/lirien-env/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Lirien Env
==========

[](#lirien-env)

[![Latest Version](https://camo.githubusercontent.com/be3113206eb1145f1c8d8b10b1b845405f981d3afd86b0e37c9275a8527a33d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c697269656e2f656e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lirien/env)[![PHP Version](https://camo.githubusercontent.com/db538aa924e03a9bbdebd47b9e9341a7ec9a4cb235668684846fd5a107cd7838/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c697269656e2f656e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lirien/env)[![Total Downloads](https://camo.githubusercontent.com/9b2d2ee7679cbb47971425ebfec682b6287e21e90ec9ca38379a719dae5a57c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c697269656e2f656e762e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lirien/env)[![License](https://camo.githubusercontent.com/7a0c4a52d2ab42a02f2da23a126a5d42f45d4b9aa6e826335f78154d6bfe830e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c697269656e2f656e762e7376673f7374796c653d666c61742d737175617265)](LICENSE)

A minimal and straightforward `.env` file loader for PHP 8.1+.

Ideal for small to medium-sized projects that need simple environment variable loading without additional dependencies.

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

[](#installation)

```
composer require lirien/env
```

Usage
-----

[](#usage)

```
use Lirien\Support\Env;

// Load the .env file (typically at application bootstrap)
Env::load(__DIR__ . '/../.env');

// Retrieve a variable
$appName = Env::get('APP_NAME');

// Set a variable at runtime (e.g. in tests)
Env::set('APP_ENV', 'testing');
```

Example `.env`
--------------

[](#example-env)

```
APP_NAME=Lirien
APP_ENV=local
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=secret

# Comments and empty lines are ignored
REDIS_HOST=127.0.0.1
```

Methods
-------

[](#methods)

- `Env::load(string $path)` - Loads variables from the specified `.env` file
- `Env::get(string $key): string` - Returns the environment variable value
- `Env::set(string $key, string value): void` - Sets or overrides a variable at runtime

> Tip: Always provide a default value when using Env::get() if the variable might not exist.

Security &amp; Best Practices
-----------------------------

[](#security--best-practices)

- Never commit your .env file — it must stay out of version control
- Store the .env file outside the public web root
- Validate and sanitize values loaded from the environment
- Use Env::set() for tests or runtime overrides, not for permanent configuration

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Every ~0 days

Total

2

Last Release

160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f3c763b9bf688267c55b17c14b46b943b299dcf36e1516c445e7740114ecc3d?d=identicon)[claudiovictors](/maintainers/claudiovictors)

---

Top Contributors

[![claudiovictors](https://avatars.githubusercontent.com/u/157994325?v=4)](https://github.com/claudiovictors "claudiovictors (3 commits)")

### Embed Badge

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

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

PHPackages © 2026

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