2017 © Pedro Peláez
 

library config

image

asgard/config

  • Saturday, August 19, 2017
  • by leyou
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,100 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Config

Build Status, (*1)

The Config package helps you manage the configuration of your application., (*2)

, (*3)

Installation

If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries., (*4)

composer require asgard/config 0.*

, (*5)

Usage in the Asgard Framework

$config = $container['config'];

The container is often accessible as a method parameter or through a ContainerAware object. You can also use the singleton but it is not recommended., (*6)

, (*7)

Usage outside the Asgard Framework

$config = new \Asgard\Config\Config;

, (*8)

Methods

Config inherits \Asgard\Common\Bag to access its data., (*9)

Besides, you can load a configuration with:, (*10)

$config->loadFile('file.yml');

Or a whole directory:, (*11)

$config->loadDir('config/');

This will load files that in the directory., (*12)

Local files, (*13)

If you want to add configuration specific to your local setup, name the file as such:, (*14)

config.local.yml

The file will be loaded after others, and is ignored by default by the Asgard application .gitignore file., (*15)

Environment files, (*16)

If you want to make configuration files specific to environments, name them as such:, (*17)

config_[env].yml

With [env] being the name of the environment., (*18)

Calling:, (*19)

$config->loadDir('config/', 'prod');

Will load default configuration files, plus all *_prod.yml files, while ignoring files like *_dev.yml, (*20)

, (*21)

Configuration file structure

A configuration file, like config.yml contains an array of parameters in YAML format:, (*22)

database:
    host: localhost
    user: root
    password:
    database: asgard

Each key can be acessed like:, (*23)

$config->get('database.user');
#or
$config['database.user'];
#or
$config['database']['user'];

, (*24)

Commands

Init

Initialize the configuration files., (*25)

Usage:, (*26)

php console config:init

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository., (*27)

License

The Asgard framework is open-sourced software licensed under the MIT license, (*28)

The Versions

19/08 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

by Michel Hognerud

13/05 2016

v0.3.1

0.3.1.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

12/05 2016

v0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

13/06 2015

v0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud

09/09 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Michel Hognerud