Recently i wrote a library to get values from environment variables and parse to the PHP data types. This library can be used to parse environment variables to PHP data types (like the casting to integer, float, null, boolean), parse the complex data structures like a JSON string and more with the contribution of the commnunity.
The library is available here: https://github.com/jpcercal/environment
Setup your environment variables with .htaccess file in a directory named "www" or "htdocs" or "public" or "web" depend of your hosting company. The content of .htaccess:
...
SetEnv APP_ENV production
...
And to get the values from environment variable (independently of the environment CLI, Apache, Nginx, PHP Built-in Server and more) to do it:
<?php
// ...
require "vendor/autoload.php";
// ...
if (Cekurte\Environment\Environment::get("APP_ENV") === "production") {
// ...
// It is your production environment ...
} else {
// ...
// It is your development environment ...
}
Enjoy it.