This class helps you load your application configs, it supports php, xml, ini and json files.

2.2.0 2016-10-04 09:48 UTC


Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads Support via Gittip

This class helps you load your application configs, it supports php, xml, ini, yml, neon and json files.

It's easy to use, and you can load multiple files with diferent formats at once


Via Composer

$ composer require masnathan/config4all


use MASNathan\Config\Config;

$config = new Config();

//You can load as many files as you want, one by one
$config->load('configs/config.php', 'configs/database.php');
//or all the files with a certain extension at the same time
//you can even load multiple format files at the same time
$config->load('configs/*.json', 'configs/*.yml');
//or can also load multiple files, regardless of the extension

//This is how you clear all the configurations

Fetching the information

//To get a value, you just need to know the path to get there
//if you want to know my name, just use the get method and pass the configuration file name
//and the keys to get my name, like this
echo $config->get('config', 'me', 'name');

//here are some other examples
echo $config->get('config', 'github');
echo $config->get('database', 'host');

//if the value that you are trying to get doesn't exist, you'll get a null
//you can also get the entire structure by calling the method get with no arguments

Setting my own configs

//You can also set new configs on the fly, or change existing ones
    ->set('a', 'b', 'c', 'value')
    ->set('config', 'me', 'name', 'Not Andre Filipe')
    ->set('database', 'host', 'first', 'localhost')
    ->set('database', 'host', 'second', 'somehost')
    ->set('this is a null field');

//This will return 'value'
echo $config->set('a', 'b', 'c');

Change log

Please see CHANGELOG for more information what has changed recently.


$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.