malotor/config-provider

There is no license information available for the latest version (dev-master) of this package.

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2017-07-23 21:13 UTC

This package is not auto-updated.

Last update: 2020-01-02 20:42:41 UTC


README

This provider add these featres:

  • Support for YAML config files
  • Allow "import" in files
  • Allow variables replacement

Requirements

  • Silex 2.0
  • PHP7
  • Phpunit 6

Install the project

$ docker-compose build
$ docker-compose run --rm composer install

Run the tests

$ docker-compose up -d tests
$ sh scripts/phpunit --converage-html ./coverage

Example

# config.yml
debug: false
# Database connections
database:
    driver:   sqlite
# config_dev.yml
imports:
  - { resource: config.yml }
debug: true
config_path : %base_path%
$app = new Application();
$app['base_path'] = '/home/user/config';

$app->register(new ConfigProvider(__DIR__ . 'config_dev.yml'), array());
#Import
echo $app['config']['database']['driver'] # sqlite
#Override
echo $app['config']['debug'] # true
#Replacement
echo $app['config']['config_path'] # /home/user/config