PHP code example of jasny / application-env

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

    

jasny / application-env example snippets


use Jasny\ApplictionEnv;

$env = new ApplicationEnv(getenv('APPLICATION_ENV') ?? 'dev');

echo "Application environment: ", (string)$env;

if ($env->is("dev")) {
   ini_set('display_errors', true);
}

$configFiles = $env->getLevels(
  from: 0,
  callback: fn(string $env) => $env === '' ? "settings.{$env}.yml" : "settings.yml"
);