PHP code example of honklegion / environment

1. Go to this page and download the library: Download honklegion/environment 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/ */

    

honklegion / environment example snippets


use HonkLegion\Environment;

// Using getenv function:
var_dump(getenv('FOO')); // string(false)

// Using Environment function:
var_dump(Environment::Bool('foo')); //bool(false)

// But we can go even further:
var_dump(Environment::Bool('BAR')); //bool(true)
var_dump(Environment::Float('BAR')); //float(1.0)

// What about multi-values?
var_dump(Environment::array('KEYS', '|', Environment::String)); //array(3) [0 => '1', 1 => '2', 2 => '3'] - notice we have strings
var_dump(Environment::array('KEYS', '|', Environment::Int)); //array(3) [0 => 1, 1 => 2, 2 => 3] - notice we have int

// Default values? No problem!
var_dump(Environment::Bool('prod', true)); //bool(true) * even bin is not set