Reference implementations for Env-Interop.

Maintainers

Package info

github.com/env-interop/impl

pkg:composer/env-interop/impl

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.0-beta2 2026-04-23 03:54 UTC

This package is auto-updated.

Last update: 2026-04-23 03:58:52 UTC


README

PDS Skeleton PDS Composer Script Names

Reference implementations of the Env-Interop interfaces for PHP 8.4+.

Installation

composer require env-interop/impl

Usage

Load a base environment file, with an optional local override:

use EnvInterop\Impl\EnvLoader;

new EnvLoader()
    ->loadEnv('.env.ini')
    ->loadEnvIfReadable('.env.local.ini');

Read values from the environment:

use EnvInterop\Impl\Env;

$env = new Env();

$pdo = new PDO(
    $env->getEnv('PDO_DSN'),
    $env->getEnv('PDO_USERNAME'),
    $env->getEnv('PDO_PASSWORD'),
);

Add or replace environment variables:

use EnvInterop\Impl\EnvSetter;

$setter = new EnvSetter();
$setter->addEnv('FEATURE_FLAG', true);   // only if not already set
$setter->setEnv('DEBUG', false);         // always replaces; null unsets

Parse environment contents directly (INI syntax, via parse_ini_string()):

use EnvInterop\Impl\EnvParser;

$parsed = (new EnvParser())->parseEnv(<<<INI
    APP_NAME = "example"
    APP_DEBUG = true
    INI);

Classes

Interface Implementation
EnvLoaderService EnvLoader
EnvParserService EnvParser
EnvSetterService EnvSetter
EnvGetter Env
EnvLoaderThrowable EnvLoaderException
EnvParserThrowable EnvParserException
EnvInvalidThrowable EnvInvalidException

All classes are in the EnvInterop\Impl namespace.

See the Env-Interop interface package for the full specification.