proximitymad / detectenv
A simple PHP class to detect environment depending on server name
Installs: 482
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
pkg:composer/proximitymad/detectenv
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 5.6.*
This package is not auto-updated.
Last update: 2025-10-12 02:20:27 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');