Skip to content

Simple PHP Class to get environment depending on server name

Notifications You must be signed in to change notification settings

nilsburg/detectenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

detectenv

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 proximity/detectenv "1.0.*"

or add

"proximity/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',
];
$env = \proximity\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 = \proximity\detectenv\DetectEnv::get($hosts, 'prod');

About

Simple PHP Class to get environment depending on server name

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages