https://github.com/brianium/habitat
Dependable environment variables for PHP
https://github.com/brianium/habitat
Last synced: 11 months ago
JSON representation
Dependable environment variables for PHP
- Host: GitHub
- URL: https://github.com/brianium/habitat
- Owner: brianium
- License: mit
- Created: 2013-06-07T17:42:02.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2020-10-31T21:31:08.000Z (over 5 years ago)
- Last Synced: 2025-07-15T05:14:01.359Z (11 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 44
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Habitat [](https://travis-ci.org/brianium/habitat)
> Because we dont always know if $_ENV is available
Habitat is a light weight wrapper over PHP's environment variable
functionality. Habitat allows the retrieval of all environment variables
when the ini setting `variables_order` does not contain the `E` flag
Examples
--------
Habitat delegates most functionality to the native php functions `getenv` and `putenv`.
If $_ENV is not available due to the `variables_order` ini setting, then Habitat's `getAll`
method will still allow access to all variables that are in `$_ENV`.
```php
use Habitat\Habit;
//equivalent of getenv('FOO')
$foo = Habitat::getenv('FOO');
//equivalent of putenv('FOO=BAR')
$wasSet = Habitat::putenv('FOO=BAR');
/**
* Returns $_ENV if set, otherwise set $_ENV via phpinfo() and
* return it
*/
$all = Habitat::getAll();
```
Parsers
-------
Habitat can support the cli and html varieties of `phpinfo`. It will detect the current sapi
and use the appropriate method to populate $_ENV