PHP code example of e-artspace / pimple-env-provider

1. Go to this page and download the library: Download e-artspace/pimple-env-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

e-artspace / pimple-env-provider example snippets


putenv('DEBUG_APP=false');

$container = new \Pimple\Container([
	'debug.app'=> true
]);

$container->register(new \EnvProvider\EnvProvider([
	'env.vars'=>[
		'debug.app'=>'env.cast.boolean'
	]
]);

assert($container['debug.app'] === true);

$container['env.overload']; // this do the magic

assert($container['debug.app'] === false);

$container['env.cast.onoff'] = $app->protect(function($str) {
	return (0===strcasecmp('on',$str));
};

$container['env.name.builder'] = app->protect(function($name) {
	return strtolower((str_replace('.', '-', $name)));;
})