2017 © Pedro PelĆ”ez
 

library utils

Various utility classes

image

datingvip/utils

Various utility classes

  • Friday, February 16, 2018
  • by kornrunner
  • Repository
  • 13 Watchers
  • 2 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

utils

Various utilitiy classes, (*1)

Env

Yet another environment utility class. Once it is setup with map of environment names to (array of) regular expression(s) to compare server HTTP host to, it provides a couple of methods to check where are we executing code. Environments can tagged as debug., (*2)

With no setup provided production environment is considered default, and development is tagged as debug., (*3)

It is considered that HTTP host belongs to a single environment, and setup ordering defines precedence if a host name matches multiple regular expressions., (*4)

Class also provides methods to check if we are running in CLI or Web. HTTPS checker is available as well., (*5)

require_once 'vendor/autoload.php';

use DatingVIP\utils\Env;

Env::setup ([
    'development' => ['/\.dev$/', '/\.test$/'], // just to display multiple regexes
    'staging' => '/^dev-/',
    'scary' => '/^hitchcock/',
    'production' => '/\.com$/',
]);

var_dump (Env::isDevelopment ('www.mysite.dev'));
var_dump (Env::isStaging ('dev-www.mysite.com'));
var_dump (Env::isScary ('hitchcock.mysite.com')); // not production, precedence
var_dump (Env::isProduction ('www.mysite.com'));

if (Env::debug ())
{
    // i can haz debug!
}

if (Env::isHTTPS ())
{
    // much secure
}

if (Env::isCLI ())
{
    // type type type
}

The Versions

16/02 2018

dev-master

9999999-dev https://github.com/DatingVIP/utils

Various utility classes

  Sources   Download

LGPLv3 LGPL-3.0-or-later

The Requires

  • php >=5.4.0

 

environment env

13/04 2014

v1.0.0

1.0.0.0 https://github.com/DatingVIP/utils

Various utility classes

  Sources   Download

LGPLv3

The Requires

  • php >=5.4.0

 

environment env