Advanced functions dotEnv tool for reading .env files for standard global and protected contexts

Installs: 252

Dependents: 7

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/jardissupport/dotenv

1.0.0 2026-02-25 17:31 UTC

README

Build Status License: PolyForm NC PHP Version PHPStan Level PSR-4 PSR-12 Coverage

Part of the Jardis Ecosystem — 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

  • 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

composer require jardissupport/dotenv

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

Full documentation, examples and API reference:

jardis.io/docs/support/dotenv

Jardis Ecosystem

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

Category Packages
Core Kernel, Entity, Workflow
Support DotEnv, Cache, Logger, Messaging, DbConnection, DbQuery, DbSchema, Validation, Factory, ClassVersion
Generic Auth
Tools Builder, Migration, Faker

Explore all packages

License

This package is licensed under the PolyForm Noncommercial License 1.0.0.

For commercial use, see COMMERCIAL.md.

Jardis Ecosystem by Headgent Development