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

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

jardissupport/dotenv
====================

Environment file loader with cascading overrides, variable interpolation, type casting, and include directives

v1.0.0(2mo ago)0618↓50%7PolyForm-Noncommercial-1.0.0PHPPHP &gt;=8.2CI passing

Since Mar 18Pushed 2mo agoCompare

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

READMEChangelog (1)Dependencies (8)Versions (6)Used By (7)

Jardis DotEnv
=============

[](#jardis-dotenv)

[![Build Status](https://github.com/jardisSupport/dotenv/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisSupport/dotenv/actions/workflows/ci.yml/badge.svg)[![License: PolyForm NC](https://camo.githubusercontent.com/6be0c0a18ef7d6aa02f611cc0eedfcaee9135ec4635235df4356327d163ea13e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d506f6c79466f726d2532304e432d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/d117944b58da8146f96b4ef7403807610a20eeb3fbcaaaf95157bbcdad1686eb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e737667)](https://phpstan.org/)[![PSR-4](https://camo.githubusercontent.com/52bb6536eb4261a007095d48b1b40fcf8bf357a0649865230901e12746a7fe80/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6175746f6c6f61642d5053522d2d342d626c75652e737667)](https://www.php-fig.org/psr/psr-4/)[![PSR-12](https://camo.githubusercontent.com/9a55c17459c810407cac6350c94a2c6f9545d3c249439e19a763f6856392bb39/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d5053522d2d31322d626c75652e737667)](https://www.php-fig.org/psr/psr-12/)[![Coverage](https://camo.githubusercontent.com/ea7daefcee71c6af386bf2627d7b85ef752935633598fffdd9c56bbeda6cd45d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d25334539302532352d627269676874677265656e)](https://github.com/jardisSupport/dotenv)

> Part of the **[Jardis Ecosystem](https://jardis.io)** — A modular DDD framework for PHP

A powerful environment configuration reader for PHP applications. Unlike traditional dotenv libraries, Jardis DotEnv supports **protected contexts** for domain-driven design — load different configurations for different bounded contexts without global state pollution.

---

Features
--------

[](#features)

- **Protected Contexts** — Load configurations into isolated arrays instead of global `$_ENV`
- **Automatic Type Casting** — Converts strings to `bool`, `int`, `float`, or `array` automatically
- **Variable Substitution** — Use `${VAR}` syntax for dynamic value resolution
- **Modular Includes** — Split configs with `load()` and `load?()` directives
- **Include Cascade** — Included files automatically resolve `.local` and `.{APP_ENV}` variants
- **Environment-specific Loading** — Auto-loads `.env.{APP_ENV}` and `.env.local` files
- **Circular Reference Detection** — Prevents infinite loops in include chains
- **Custom Exception Hierarchy** — Typed exceptions for missing files, unreadable files, parse errors, and circular includes
- **Home Directory Expansion** — Automatically expands `~` to user home path

---

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

[](#installation)

```
composer require jardissupport/dotenv
```

Quick Start
-----------

[](#quick-start)

```
use JardisSupport\DotEnv\DotEnv;

$dotEnv = new DotEnv();

// Load into global scope ($_ENV, $_SERVER, putenv)
$dotEnv->loadPublic('/path/to/app');

// Load into protected scope (returns array, no global pollution)
$domainConfig = $dotEnv->loadPrivate('/path/to/domain');
```

Documentation
-------------

[](#documentation)

Full documentation, examples and API reference:

**→ [jardis.io/docs/support/dotenv](https://jardis.io/docs/support/dotenv)**

Jardis Ecosystem
----------------

[](#jardis-ecosystem)

This package is part of the Jardis Ecosystem — a collection of modular, high-quality PHP packages designed for Domain-Driven Design.

CategoryPackages**Core**Kernel, Entity, Workflow**Support**DotEnv, Cache, Logger, Messaging, DbConnection, DbQuery, DbSchema, Validation, Factory, ClassVersion**Generic**Auth**Tools**Builder, Migration, Faker**→ [Explore all packages](https://jardis.io/docs)**

License
-------

[](#license)

This package is licensed under the [PolyForm Noncommercial License 1.0.0](LICENSE).

For commercial use, see [COMMERCIAL.md](COMMERCIAL.md).

---

**[Jardis Ecosystem](https://jardis.io)** by [Headgent Development](https://headgent.com)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance86

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

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 ~20 days

Total

2

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

[![Headgent](https://avatars.githubusercontent.com/u/245725954?v=4)](https://github.com/Headgent "Headgent (1 commits)")

---

Tags

loaderContextenvironmentenvdotenvDomain Driven DesignJardisPortjardisjardisSupport

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[vlucas/phpdotenv

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

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

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[m1/env

Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.

6412.0M21](/packages/m1-env)[diarmuidie/envpopulate

Tool to interactively populate a `.env` file based on an `.env.example` file whenever Composer installs or updates.

1892.0k](/packages/diarmuidie-envpopulate)[zepgram/magento-dotenv

Simple autoloader to integrate the Symfony Dotenv component into Magento2

1371.3k](/packages/zepgram-magento-dotenv)[nystudio107/dotenvy

Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents.

326.9k](/packages/nystudio107-dotenvy)

PHPackages © 2026

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