PHPackages                             brianium/habitat - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. brianium/habitat

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

brianium/habitat
================

A dependable php environment

v1.0.0(12y ago)4412.0M—2.7%[1 issues](https://github.com/brianium/habitat/issues)7MITPHP

Since Jun 8Pushed 5y ago2 watchersCompare

[ Source](https://github.com/brianium/habitat)[ Packagist](https://packagist.org/packages/brianium/habitat)[ RSS](/packages/brianium-habitat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (7)

Habitat [![Build Status](https://camo.githubusercontent.com/76f93fa29c4809c2db411f1158d66b4640f139c396a36b7936b52c1d2efcbce8/68747470733a2f2f7472617669732d63692e6f72672f627269616e69756d2f686162697461742e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/brianium/habitat)
=======================================================================================================================================================================================================================================================================================

[](#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
--------

[](#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`.

```
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
-------

[](#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

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4728d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f71e23eec19a24f64f37c622e76e725c9a580f83ff40c411da9bad97e0a49089?d=identicon)[brianium](/maintainers/brianium)

---

Top Contributors

[![brianium](https://avatars.githubusercontent.com/u/636651?v=4)](https://github.com/brianium "brianium (14 commits)")[![jdufresne](https://avatars.githubusercontent.com/u/347634?v=4)](https://github.com/jdufresne "jdufresne (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brianium-habitat/health.svg)

```
[![Health](https://phpackages.com/badges/brianium-habitat/health.svg)](https://phpackages.com/packages/brianium-habitat)
```

###  Alternatives

[facile-it/php-codec

A partial porting of io-ts in PHP

106.7k](/packages/facile-it-php-codec)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
