PHP code example of phossa2 / env

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

    

phossa2 / env example snippets


  
  // ...
  $env = new Phossa2\Env\Environment();

  # load env
  $env->load(__DIR__ . '/.env');

  // use your env
  echo getenv('APP_DIR');
  

  env->load('./.env', $overload = false);
  

  # spaces before and after '=' is allowed. NOT recommended though
  ROOT_DIR = /var/tmp
  

  # set current file
  MY_FILE=${BASH_SOURCE##*/}

  # set root dir to current dir
  ROOT_DIR=${BASH_SOURCE%/*}
  

  HOST=${_SERVER.HTTP_HOST}