PHP code example of infrajs / env

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

    

infrajs / env example snippets



//Определено окружение или нет. Проверяется 1 - GET -env и 2 - COOKIE -env.
Env::is();

//Возвращает имя окружение. Если окруежние определено по умолчанию, то имя - пустая строка.
Env::name();

//Возвращает значение указанного параметра окружения
Env::get(name);

//Для определения нового параметра окружения нужно указать функцию определения значения по умолчанию и функцию проверки установленного пользователем значения.
Env::add(name, $fndef, $fncheck);


Env::add('region', function () {
  return 'samara';
}, function ($newval) {
  return in_array($newval, array('togliatti','samara'));
});
location.replace('?-env=...');