Class: Envconf

Wraps Appconf's getters in a check to see whether the equivalent environment variable has been set, and if so, returns that instead. For implementing sensiting settings in apps that you want to inject via environment variables and use the built-in system as a transparent fallback.

The naming of the environment variables are the concatenated names of the app, section, and setting. For example:

<?php

// Returns $_ENV['MYAPP_S3_ACCESS_TOKEN'] if set.
// Otherwise, returns Appconf::myapp ('S3', 'access_token')
$token = Envconf::myapp ('S3', 'access_token');

// Alternate syntax
$token = Envconf::get ('myapp', 'S3', 'access_token');

Note that, unlike Appconf::get(), this class returns individual values only. For example, you can't call Envconf::get ('myapp', 'Section') to retrieve an array of values. This corresponds to Elefant's use of INI file sections.

Properties

No properties.

Methods

public static __callStatic ($app, $args)

Get an individual configuration value for a given app setting. Use the app name as the method name, using the form:

Appconf::appname ($section, $setting);

public static get ($app, $section, $setting)

Get an individual configuration value for an app.

  • $app is the app name
  • $section is the section of the settings
  • $setting is the individiual setting name