PHPackages                             loshmis/simple-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. loshmis/simple-config

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

loshmis/simple-config
=====================

Simple configuration loader

v1.0.1(11y ago)019MITPHP

Since Mar 29Pushed 11y ago1 watchersCompare

[ Source](https://github.com/loshmis/simple-config)[ Packagist](https://packagist.org/packages/loshmis/simple-config)[ RSS](/packages/loshmis-simple-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Simple Config
-------------

[](#simple-config)

[![Build Status](https://camo.githubusercontent.com/0730fbb1ffd6ebc2d5927309ac637a6c8739ff596ea656cb1d193460ee059ec4/68747470733a2f2f7472617669732d63692e6f72672f6c6f73686d69732f73696d706c652d636f6e6669672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/loshmis/simple-config)

Simple Config provides a convenient and classy way to load multiple configuration files from your configuration directory and it is inspired by [Laravel 5](http://laravel.com) configuration loading (it actually use [illuminate/config](https://github.com/illuminate/config) package for providing access to config data). It is mainly created to provide simple and powerful configuration loading for [Slim Framework](http://www.slimframework.com/), but it can be used with any PHP application.

Installation
------------

[](#installation)

You can install it via composer by typing the following command in your terminal

```
composer require loshmis/simple-config
```

or you can include it to your composer.json file

```
"require": {
    "loshmis/simple-config": "~1.0"
}
```

Usage with Slim
---------------

[](#usage-with-slim)

If you want to use it with Slim PHP Framework, you can do it like this (I'm placing it in my index.php file where I instantiate my Slim application, but you can place it anywhere you want, just make sure that you have provided correct configuration path)

```
//index.php

require 'vendor/autoload.php';

$app = new \Slim\Slim();

//path to your config directory
define('CONFIG_PATH', __DIR__ . '/config');

$app->container->singleton('config.loader', function($c) {
    return new \Loshmis\SimpleConfig\Loader (
        CONFIG_PATH,
        new Symfony\Component\Finder\Finder
    );
});

$app->container->singleton('config', function($c) {
    return new \Loshmis\SimpleConfig\Config($c['config.loader']);
});
```

And you can then manipulate with your configuration the same way you do in Laravel 5 (and 4) application.

Let's assume that you have file called **app.php** inside your config directory and inside that file you have the following PHP code:

```
