vyse / environment
1.0.2
2026-06-27 10:53 UTC
Requires
- php: ^8.5
Requires (Dev)
README
Simple PHP class to manage environment variables.
Installation
composer require vyse/environment
Usage
use Vyse\Environment\GetEnv;
$getEnv = new GetEnv;
try {
$foo = $getEnv->string('FOO');
$bar = $getEnv->int('BAR');
$baz = $getEnv->bool('BAZ');
} catch (Runtime Exception $ex) {
// not defined
}
Testing
Make sure to enable some variation of bypass finals in bootstrap.php.
<?php
declare(strict_types=1);
use Vyse\Toolchain\PhpUnit\Bypass\PhpUnitMutator;
PhpUnitMutator::enable();
use Vyse\Environment\GetEnv;
$getEnv = $this->createStub(GetEnv::class);
$getEnv->method('string')->willReturn('foo');
$getEnv->method('int')->willThrowException(new RuntimeException);