robotdance/php-app-config

A PHP helper component to store package/application settings

v0.0.9 2016-06-28 14:30 UTC

This package is not auto-updated.

Last update: 2024-05-11 17:01:47 UTC


README

Code Climate Test Coverage Issue Count Build Status

PHP-app-config is a component to store application/package settings, also capable of storing it per environment if necessary.

Setup

PHP-app-config uses Composer as dependency management tool. Create or ppdate your composer.json file and run:

$ composer install or $ composer update

Use

Create a folder called config/ at your app/package, and put your YAML config.yml file there. (an example of valid YAML file can found in the source). Then call Config::get, in one of the ways below.

YAML Config file structure

Your YAML config.yml file may look like this:

some_setting:
  development: some setting development
  test: some setting test
  production: some setting production

another_setting: another setting without environment

This way you can store settings depending on environment or not. Your choice. In order to have environment specific settings, you must set an environment variable called "ENVIRONMENT", with a value that can be found at your config file.

Example

The example below will try to find the key variable_name.[environment] at /config/config.yml:

use robotdance\Config;
...
$value = Config::get('variable_name');

Running tests

$ ./bin/phpunit

Contribute

Fork, write tests, code, submit pull request. Coverage must remains at 100%.