proximitymad/detectenv

There is no license information available for the latest version (v1.0.2) of this package.

A simple PHP class to detect environment depending on server name

v1.0.2 2016-11-15 15:25 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:52:48 UTC


README

Simple PHP Class to get environment depending on server name

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist proximitymad/detectenv "1.0.*"

or add

"proximitymad/detectenv": "1.0.*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

$hosts = [
    'mydevhost.dev'=>'dev',
    'mytesthost.com'=>'test',
    'myprodhost.com'=>'prod',
    'myHostName'=>'console',
];
$env = \proximitymad\detectenv\DetectEnv::get($hosts);

By default if no host is found it will return null, you can change the default host by adding the second parameter:

$env = \proximitymad\detectenv\DetectEnv::get($hosts, 'prod');