Configuration tool for your PHP applications

Installs: 225

Dependents: 0

Stars: 19

Watchers: 3

Forks: 1

1.1.3 2014-07-18 14:00 UTC



Kengai is a simple but powerful configuration tool for your PHP applications. Anybody is welcome to help and contribute to this project.

About this project

The idea is simple :

  • Manage configurations from any formats with a tree structure (YAML, JSON, INI, etc.) in a simple and optimized way.
  • All data are stored in a common tree ordered by namespaces.
  • The possibility to use any cache system (like APC).
  • Event system for advanced use cases, powered by the Symfony 2 event dispatcher component.


Here is a example of a basic usage:


use Kengai\Manager as Kengai;
use Kengai\SourceReader\YAML;
use Kengai\SourceReader\JSON;

// Create a Kengai manager instance
$kengai = new Kengai();

// Import your configuration files
$kengai->add(new YAML('myconfig.yml', 'myconfig'));

// Example of JSON support
$kengai->add(new JSON('composer.json', 'composer'));

// Fetch data

As you can see in this example, all sources are registered with the add() method before fetch() call. When all sources are registered, you can use fetch() to proceed the importing process. After this, you can not use add() anymore! In the case of a cache manager is registered, the importing process will first verify the cache freshness from your cache manager, then just restore it or reload all sources if needed.

Here's is a configuration reading example :

$bar = $kengai->get('foo.bar');


Cache support

You can use any cache system by using CacheManagerInterface :


use Kengai\Manager as Kengai;
use Kengai\SourceReader\YAML;
use Kengai\CacheManager\APC;

// Create a Kengai manager instance with APC support
$kengai = new Kengai(new APC());


// Fetch data