r3n0e0 / env-php
A utility that provides several functions for accessing environment variables.
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/r3n0e0/env-php
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ^5.7 || ^6.2
This package is not auto-updated.
Last update: 2025-10-18 20:36:26 UTC
README
This is a utility that provides several functions for accessing environment variables.
Inspired by the env library for Python.
Example Usage
Environment variables:
GITHUB_USER=xxx
GITHUB_TOKEN=yyy
API_TOKEN=zzz
Easy to use as follows:
>>> require __DIR__ . '/vendor/autoload.php';
>>> use EnvPHP\Env;
>>> $env = Env::prefix('GITHUB_');
>>> var_dump($env);
array(2) {
'user' =>
string(3) "xxx"
'token' =>
string(3) "yyy"
}
>>> $env = Env::suffix('_TOKEN');
>>> var_dump($env);
array(2) {
'github' =>
string(3) "yyy"
'api' =>
string(3) "zzz"
}
Thanks
- Kenneth Reitz (kennethreitz)