r3n0e0/env-php

A utility that provides several functions for accessing environment variables.

0.1.0 2017-07-21 09:13 UTC

This package is not auto-updated.

Last update: 2024-11-02 15:43:55 UTC


README

Build Status

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