PHPackages                             thesmart/environment - 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. thesmart/environment

ActiveLibrary

thesmart/environment
====================

Easily manage database connection strings or other configuration data that changes across server environments such a dev and prod.

v0.0.2(13y ago)423MITPHPPHP &gt;=5.3.0

Since Jul 27Pushed 13y agoCompare

[ Source](https://github.com/thesmart/php-environment)[ Packagist](https://packagist.org/packages/thesmart/environment)[ Docs](https://github.com/thesmart/php-environment)[ RSS](/packages/thesmart-environment/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Environment PHP Library by John Smart ([@thesmart](https://github.com/thesmart))
================================================================================

[](#environment-php-library-by-john-smart-thesmart)

Easily manage database connection strings or other configuration data that changes across server environments such a dev and prod.

Example
-------

[](#example)

This runs one time at the start of your void main:

```
// construct an instance
new Env('dev');

// development http server url
Env::set('url', array(
	'scheme' => isset($_SERVER) && isset($_SERVER['HTTPS']) ? 'https' : 'http',
	'domain' => 'dev-github.com'
));

// development memcached server connection strings
Env::set('memached.main', array(
	'port' => 11211,
	'addr' => '127.0.0.1'
));

// alternative syntax
Env::set('facebook.appId', '012345678');
Env::set('facebook.secret', '000000000000000000000000000000'); // keep secret
Env::set('facebook.namespace', 'app_name_space');
Env::set('facebook.url', 'https://apps.facebook.com/app_name_space');

```

Later, you can easily access current environment variables:

```
// access using dot-notation
$facebookConfig = Env::get('facebook');

$memcached = new \Memcached();
$memcached->addServer(Env::get('memcached.main.addr'), Env::get('memcached.main.port'));

if (Env::has('memcached')) {
	// go cache some shit
}

```

Mix with OS environment variables to define which configuration to use:

```
$configToSet	= isset($_SERVER['conf']) ? $_SERVER['conf'] : 'prod';
require_once PATH_CONFIG . $configToSet . '.php';

```

Like this project?
==================

[](#like-this-project)

Check out my others. [@thesmart](https://twitter.com/thesmart)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~0 days

Total

2

Last Release

5039d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11f682ea6d98e41ccb56db0a284ac5b085fd31d40c3119cf8c3e493f87498c0a?d=identicon)[thesmart](/maintainers/thesmart)

---

Top Contributors

[![thesmart](https://avatars.githubusercontent.com/u/280877?v=4)](https://github.com/thesmart "thesmart (2 commits)")

---

Tags

configurationconfigenvironmentconnection stringsconnection parameters

### Embed Badge

![Health badge](/badges/thesmart-environment/health.svg)

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

###  Alternatives

[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[league/config

Define configuration arrays with strict schemas and access values with dot notation

564302.2M24](/packages/league-config)[danack/configurator

Generates config files from PHP, JSON and Yaml data files.

159.9k](/packages/danack-configurator)

PHPackages © 2026

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