PHP code example of agashe / env-parser

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

    

agashe / env-parser example snippets




nvParser\Parser;

$parser = new Parser();

$data = $parser->parse('/path/to/my/env/file');

var_dump($data);

$data = $parser->parse('/path/to/my/env/file');

echo $data['DATABASE_NAME']; // app_db
echo $_ENV['DATABASE_NAME']; // app_db
echo $_SERVER['DATABASE_NAME']; // app_db

array(3) {
  ["EMAIL_DOMAIN"]=>
  string(21) "our-emails-domain.com"
  ["ADMIN_USERNAME"]=>
  string(11) "super-admin"
  ["ADMIN_EMAIL"]=>
  string(33) "[email protected]"
}