2017 © Pedro Peláez
 

library environment

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

image

thesmart/environment

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

  • Friday, July 27, 2012
  • by thesmart
  • Repository
  • 0 Watchers
  • 3 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

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., (*1)

Example

This runs one time at the start of your void main:, (*2)

// 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:, (*3)

// 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:, (*4)

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

Like this project?

Check out my others. @thesmart, (*5)

The Versions

27/07 2012

dev-master

9999999-dev https://github.com/thesmart/php-environment

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

  Sources   Download

MIT

The Requires

 

configuration config environment connection strings connection parameters

27/07 2012

v0.0.1

0.0.1.0 https://github.com/thesmart/php-environment

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

  Sources   Download

MIT

The Requires

 

configuration config environment connection strings connection parameters

27/07 2012

v0.0.2

0.0.2.0 https://github.com/thesmart/php-environment

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

  Sources   Download

MIT

The Requires

 

configuration config environment connection strings connection parameters