env-interop / impl
Reference implementations for Env-Interop.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/env-interop/impl
Requires
- php: ^8.4
- env-interop/interface: 1.x@dev
Requires (Dev)
- pds/composer-script-names: ^1.0
- pds/skeleton: ^1.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-12-18 02:07:48 UTC
README
The reference EnvLoaderService implementation uses parse_ini_string() for
environment file parsing, and loads only into $_ENV.
use EnvInterop\Impl\EnvLoader; // loads a base required file and an optional local file, // then checks that required variables have been loaded. new EnvLoader() ->loadEnv('.env.ini') ->loadEnvIfExists('.env.local.ini') ->assertEnv([ 'PDO_DSN', 'PDO_USERNAME', 'PDO_PASSWORD', ]);
The reference implementation for EnvGetter reads from a copy of $_ENV.
use EnvInterop\Impl\Env; use PDO; $env = new Env(); $pdo = PDO::connect( $env->getEnv('PDO_DSN'), $env->getEnv('PDO_USERNAME'), $env->getEnv('PDO_PASSWORD'), );