PHP code example of rammewerk / environment

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

    

rammewerk / environment example snippets


use Rammewerk\component\environment\src\Environment;

$env = new Environment();

// Load from environment variable file
$env->load( ROOT_DIR . '.env');

// Get value from environment
$debug_mode = $env->get( 'DEBUG_MODE' );

// Or use the built-in typed getters which returns true or false, defaults to false
$debug_mode = $env->getBool('DEBUG_MODE');


$env->load( ROOT_DIR . '.env');

# Warning: will overwrite value for keys that exist in both files.
$env->load( ROOT_DIR . '.env-app');

# You can also define new variables or overwrite values on the fly.
$env->set('NEW_KEY', 'new value');

$env->validate( static function(Validator $env) {
    $env->

$env->getString('KEY1'); // Returns string or null
$env->getInt('KEY2'); // Returns int or null
$env->getFloat('KEY3'); // Returns float or null
$env->getBool('KEY4'); // Returns bool, true or false, defaults to false
$env->getArray('KEY5'); // Returns array or null