robotdance / php-app-config
A PHP helper component to store package/application settings
Requires
- php: >=5.3.2
- symfony/yaml: ~3.1
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: 4.8.24
README
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%.