PHP code example of maatwebsite / yamlenv

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

    

maatwebsite / yamlenv example snippets


$yamlenv = new Yamlenv\Yamlenv(__DIR__);
$yamlenv->load();

$yamlenv = new Yamlenv\Yamlenv(__DIR__, 'myconfig');
$yamlenv->load();

$s3_bucket = getenv('S3_BUCKET');
$s3_bucket = $_ENV['S3_BUCKET'];
$s3_bucket = $_SERVER['S3_BUCKET'];

$s3_bucket = $request->env('S3_BUCKET');
$s3_bucket = $request->getEnv('S3_BUCKET');
$s3_bucket = $request->server->get('S3_BUCKET');
$s3_bucket = env('S3_BUCKET');

$yamlenv = new Yamlenv\Yamlenv(__DIR__, 'emv.yml', true);
$yamlenv->load();

$s3_bucket = getenv('S3_BUCKET'); // return will_be_uppercase
$s3_bucket = getenv('s3_bucket'); // returns null

$yamlenv = new Yamlenv\Yamlenv(__DIR__);
$yamlenv->overload();

$yamlenv->

$yamlenv->

$yamlenv->

$yamlenv->

$yamlenv->