Download the PHP package jstewmc/detect-environment without Composer
On this page you can find all versions of the php package jstewmc/detect-environment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jstewmc/detect-environment
More information about jstewmc/detect-environment
Files in jstewmc/detect-environment
Package detect-environment
Short Description Detect an application's environment
License MIT
Informations about the package detect-environment
detect-environment
Detect an application's environment.
Usage
To instantiate the service, you MUST pass the environment variable name and the environment variable values, indexed by application environment name:
In the example above, the service would detect the environment as development, testing, staging, and production when the APP_ENV
environment was 'foo'
, 'bar'
, 'baz'
, and 'qux'
, respectively.
Keep in mind, the environment variable name, the environment variable values, and the application environment names MAY be any string. The environment variable values and the application environment names are case-insensitive.
You can check the application's environment using isX()
methods, where X
is any valid application environment name:
Environment variable
In the examples above, the environment variable was set using the putenv()
function. However, in the real world, you should define the environment variable in your server configuration (e.g., .htaccess
, httpd.conf
, etc).
No matter where you define the environment variable, it MUST be accessible to PHP's getenv function.
That's it!
License
Author
Jack Clayton
Version
2.0.0, October 2, 2016
- Add
__invoke()
method to return environment name. - Rename class to
DetectEnvironment
. The longer name seems more intentional.
1.0.0, August 13, 2016
- Major release
- Update
composer.json
0.2.0, August 13, 2016
- Refactor to support user-defined environments
0.1.0, June 25, 2016
- Initial release