Download the PHP package flavioheleno/env without Composer
On this page you can find all versions of the php package flavioheleno/env. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download flavioheleno/env
More information about flavioheleno/env
Files in flavioheleno/env
Package env
Short Description Handle environment variables like a breeze.
License mit
Homepage https://github.com/flavioheleno/env
Informations about the package env
env
Handle environment variables like a breeze.
Install with composer
Read or Required?
This library comes with two helpers:
Env\Read
, which will try to read a variable and return its value or fallback to the$default
value when the variable isn't set;Env\Required
, which will try to read a variable and return its value or throw an exception when the variable isn't set.
Usage
You can read environment variables with:
On the other hand, you can require environment variables with:
Immutable environment
The library loads the environment variables into a internal copy on the first method call.
If you ever need to update the internal copy, you can do that with:
or:
Available methods
All methods below are available in both the Env\Read
and Env\Required
helpers.
- updateEnv: Updates the internal env var copy;
- asString:: Returns the value as a string;
- asArray: Returns the values as an array (comma separated);
- asInteger: Returns the value as an integer;
- asFloat: Returns the value as a float;
- asBool: Returns the value as a boolean;
- fromJson: Returns the value as a json decoded value/object;
- fromSerialized: Returns the value as a unserialized value/object.
Contributing
There are a few helper scripts that can be called by composer, such as:
- Static Code Analysis:
php composer.phar run check
- Code Linting:
php composer.phar run lint
- Tests:
php composer.phar run test
NOTE: to run the Code Linting, you must download the ruleset from here first.
License
This library is licensed under the MIT License.