Download the PHP package oscarotero/env without Composer
On this page you can find all versions of the php package oscarotero/env. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oscarotero/env
More information about oscarotero/env
Files in oscarotero/env
Package env
Short Description Simple library to consume environment variables
License MIT
Homepage https://github.com/oscarotero/env
Informations about the package env
env
Simple library to get environment variables converted to simple types.
Installation
This package is installable and autoloadable via Composer as oscarotero/env.
Example
Available conversions
"false"
is converted to booleanfalse
"true"
is converted to booleantrue
"null"
is converted tonull
- If the string contains only numbers is converted to an integer
- If the string has quotes, remove them
Options
To configure the conversion, you can use the following constants (all enabled by default):
Env::CONVERT_BOOL
To convert boolean valuesEnv::CONVERT_NULL
To convert null valuesEnv::CONVERT_INT
To convert integer valuesEnv::STRIP_QUOTES
To remove the quotes of the strings
There's also additional settings that you can enable (they're disabled by default)
Env::USE_ENV_ARRAY
To get the values from$_ENV
, insteadgetenv()
.Env::USE_SERVER_ARRAY
To get the values from$_SERVER
, insteadgetenv()
.Env::LOCAL_FIRST
To get first the values of locally-set environment variables.
Default value
By default, if the value does not exist, returns null
, but you can change for any other value:
The env() function
You can use the env()
function, like in Laravel or other frameworks:
Please see CHANGELOG for more information about recent changes.
The MIT License (MIT). Please see LICENSE for more information.
All versions of env with dependencies
ext-ctype Version *