ENV library

Maintainers

Package info

github.com/krzysztofzylka/env

pkg:composer/krzysztofzylka/env

Statistics

Installs: 1 412

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.5 2025-07-04 04:31 UTC

This package is auto-updated.

Last update: 2026-03-04 05:49:08 UTC


README

This class is used for loading and parsing environment variables from a file.

Install

composer require krzysztofzylka/env

Load env file

$env = new \Krzysztofzylka\Env\Env();
$env->loadFromFile('/path/to/env/file');

Load multiple env file

$env = new \Krzysztofzylka\Env\Env();
$env->loadFromFile(['/path/to/env/file', '/path/to/env/file', ...]);

Load from system (getenv())

$env = new \Krzysztofzylka\Env\Env();
$env->loadFromSystem();

Example ENV file content

DB_HOST=localhost
DB_NAME=testDB
DB_USER=username
DB_PASS=password

Exceptions

File not found: If the given file path does not exist a File not found exception will be thrown.