Download the PHP package cekurte/environment without Composer
On this page you can find all versions of the php package cekurte/environment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package environment
Environment
- A simple library (with all methods covered by php unit tests) to increase the power of your environment variables, contribute with this project!
Installation
- The package is available on Packagist.
- The source files is PSR-2 compatible.
- Autoloading is PSR-4 compatible.
Documentation
Setup your variables to PHP with putenv("KEY=VALUE")
or put your environment variables into OS directly. Additionally you can use this library to perform this task vlucas/phpdotenv (we recommend that you use this library).
And now, use our library to get values and increase the power of your environment variables.
This command will get the value of the environment variable and will convert values to respective php data type.
Actually are available the following resources to process your environment variables:
Examples
In this section you can see the examples to all resource types.
ArrayResource
The array resource parse a value from environment variable that is a string to the array php data type. Supposing that there exists an environment variable named "ENV_ARRAY" with the following value [1,2,3,"key"=>"value"].
When you read this environment variable with our library, then it will convert the data to the correct data type (in this case to array) using the ArrayResource class.
BooleanResource
The boolean resource parse a value from environment variable that is a string to the boolean php data type. Supposing that there exists an environment variable named "ENV_BOOL" with the following value true.
When you read this environment variable with our library, then it will convert the data to the correct data type (in this case to boolean) using the BooleanResource class.
JsonResource
The json resource parse a value from environment variable that is a string to the array php data type. Supposing that there exists an environment variable named "ENV_JSON" with the following value {"key":"value"}.
When you read this environment variable with our library, then it will convert the data to the correct data type (in this case to array) using the JsonResource class.
NullResource
The null resource parse a value from environment variable that is a string to the null php data type. Supposing that there exists an environment variable named "ENV_NULL" with the following value null.
When you read this environment variable with our library, then it will convert the data to the correct data type (in this case to null) using the NullResource class.
NumericResource
The numeric resource parse a value from environment variable that is a string to the numeric php data type (an integer or a float). Supposing that there exists an environment variable named "ENV_NUMERIC" with the following value 123.
When you read this environment variable with our library, then it will convert the data to the correct data type (in this case to int) using the NumericResource class.
UnknownResource
The unknown resource no parse the values from environment variable and is used to get values when all resource types can not parse the data. Supposing that there exists an environment variable named "ENV_UNKNOWN" with the following value "unknown".
When you read this environment variable with our library, then it will get the raw value using the UnknownResource class.
If you liked of this library, give me a star =).
Contributing
- Give me a star =)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Make your changes
- Run the tests, adding new ones for your own code if necessary (
vendor/bin/phpunit
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request