PHPackages                             adrenalinkin/config-helper - 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. adrenalinkin/config-helper

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

adrenalinkin/config-helper
==========================

Extends Symfony Dependency Injection Component and provides store configurations in each bundles separately by common yaml-file

v1.0.6(7y ago)0702MITPHPPHP ~5.4||~7.0

Since Jul 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/adrenalinkin/config-helper)[ Packagist](https://packagist.org/packages/adrenalinkin/config-helper)[ RSS](/packages/adrenalinkin-config-helper/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (8)Used By (2)

Config Helper [![На Русском](https://camo.githubusercontent.com/feb4c9ee227a5ee3a5d4e83a8a5b888b2e4b666d6cc2fb985c3bf404f8f271ac/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2544302539462544302542352544312538302544302542352544302542392544312538322544302542385f2544302542442544302542302d2544302541302544312538332544312538312544312538312544302542412544302542382544302542392d677265656e2e7376673f7374796c653d666c61742d737175617265)](./README.RU.md)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#config-helper-)

Introduction
------------

[](#introduction)

Component allows extend standard class `Symfony\Component\DependencyInjection\Extension\Extension` and open possibility for collect `YAML` configurations across all registered bundles.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this component:

```
    composer require adrenalinkin/config-helper
```

*This command requires you to have [Composer](https://getcomposer.org) install globally.*

Usage examples and compare with standard methods
------------------------------------------------

[](#usage-examples-and-compare-with-standard-methods)

Let's say we have two bundles in our project. Bundles contains business-logic of the two separate system parts:

- `AcmeBundle` with entities `AcmeBundle:User` and `AcmeBundle:Position`
- `AcmePostBundle` with entity `AcmePostBundle:Post`

Imagine you need to add configuration for each entity. Let's say we need configuration which should determine user's system role for get access to specific functionality. For the configuration creation has been created bundle `AcmeConfigBundle`. Configuration example:

```
acme_config:
    AcmeBundle:User:     ROLE_USER_ADMIN # key - name of the entity; value - role
    AcmeBundle:Position: ROLE_USER_ADMIN
    AcmePostBundle:Post: ROLE_POST_ADMIN
```

### Standard methods

[](#standard-methods)

We can put configuration into global configuration file `app/config/config.yml`:

```
# app/config/config.yml

# other bundle's configurations

acme_config:
    AcmeBundle:User:     ROLE_USER_ADMIN
    AcmeBundle:Position: ROLE_USER_ADMIN
    AcmePostBundle:Post: ROLE_POST_ADMIN

# other bundle's configurations
```

Also, we can put configuration into `AcmeConfigBundle` bundle under specific configuration file and load that from `AcmeConfigExtension`:

```
#Acme/ConfigBundle/Resources/config/custom.yml
acme_config:
    AcmeBundle:User:     ROLE_USER_ADMIN
    AcmeBundle:Position: ROLE_USER_ADMIN
    AcmePostBundle:Post: ROLE_POST_ADMIN
```

However, both of method, for our realisation, got one flaw. All time when we will create new bundles - we will need modify global configuration file or configuration file in the `AcmeConfigBundle`. **Both situation provoke a hard-linking between separate parts of the project**

### Component usage

[](#component-usage)

To prevent hard-linkin between separate parts of the project you need:

- Choose file name for configuration store, for example `acme_config.yml`.
- Extends `AcmeConfigExtension` from [AbstractExtension](./Extension/AbstractExtension.php):

```
