PHPackages                             hello-motto/config-service-provider - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. hello-motto/config-service-provider

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

hello-motto/config-service-provider
===================================

A service provider to configurate silex ~2.0 with yaml, json and php files

1.0(9y ago)1231GPL-3.0+PHP

Since Mar 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/hello-motto/config-service-provider)[ Packagist](https://packagist.org/packages/hello-motto/config-service-provider)[ RSS](/packages/hello-motto-config-service-provider/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

ConfigServiceProvider for Silex 2
=================================

[](#configserviceprovider-for-silex-2)

This is a Service Provider that permits to use YAML, JSON and PHP config files in a Silex app.

Requirements
------------

[](#requirements)

- silex/silex: 2.X

Suggested
---------

[](#suggested)

- symfony/yaml: 3.X

Installation
============

[](#installation)

Install with Composer:

```
$ composer require hello-motto/config-service-provider dev-master

```

Or add to composer.json

```
"require": {
    "hello-motto/config-service-provider": "dev-master"
}
```

Usage
=====

[](#usage)

This Provider will parse your YAML, JSON and PHP files to set config variables. Those config variables are available through `$app['config']['myVariable']`. Some special variables you can define (parameters variable) also are available through `$app['parameters']`. All the variables that are contained in the several config files are recursively merged in a array.

\##Add files

You can pass one or several files to the ServiceProvider in the 'config.files' argument. No matter if it's a json, yaml or php file

```
$app->register(new HelloMotto\Silex\Config\ConfigServiceProvider(), [
    'config.files' => [
        PATH_TO_FIRST_FILE,
        PATH_TO_SECOND_FILE,
        PATH_TO_THIRD_FILE,
        etc.
    ]
]);
```

where `PATH_TO_CONFIG_FILE` is location of YML, JSON or PHP file with configuration for example

```
__DIR__. "/config/config.yml",
__DIR__. "/config/config.json",
__DIR__. "/config/config.php",
```

### Files example :

[](#files-example-)

**config/config.php**

```
