vyse/environment

Maintainers

Package info

github.com/vyse-dx/php-environment

pkg:composer/vyse/environment

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.2 2026-06-27 10:53 UTC

This package is auto-updated.

Last update: 2026-06-27 10:55:20 UTC


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);