2017 © Pedro Pelรกez
 

symfony-bundle symfony-config-manipulator-bundle

Utilities to automatically organize Symfony2 YAML config files

image

c33s/symfony-config-manipulator-bundle

Utilities to automatically organize Symfony2 YAML config files

  • Monday, June 20, 2016
  • by vworldat
  • Repository
  • 2 Watchers
  • 1 Stars
  • 15,171 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

Keep your Symfony2 YAML config files organized

Build Status SensioLabsInsight codecov.io, (*1)

Do you hate stuffing tons of config into a single config.yml file, losing track of all the sections inside the file? Then this is for you!, (*2)

This bundle provides some general-purpose YAML and Symfony config manipulation tasks. The most important one is to split the Symfony app/config/config*.yml files into separate sections, leading to a structure like this:, (*3)

# Symfony Standard Edition 2.7.3

app/config
โ”œโ”€โ”€ config
โ”‚ย ย  โ”œโ”€โ”€ assetic.yml
โ”‚ย ย  โ”œโ”€โ”€ doctrine.yml
โ”‚ย ย  โ”œโ”€โ”€ framework.yml
โ”‚ย ย  โ”œโ”€โ”€ parameters.yml
โ”‚ย ย  โ”œโ”€โ”€ swiftmailer.yml
โ”‚ย ย  โ””โ”€โ”€ twig.yml
โ”‚
โ”œโ”€โ”€ config_dev
โ”‚ย ย  โ”œโ”€โ”€ assetic.yml
โ”‚ย ย  โ”œโ”€โ”€ framework.yml
โ”‚ย ย  โ”œโ”€โ”€ monolog.yml
โ”‚ย ย  โ”œโ”€โ”€ swiftmailer.yml
โ”‚ย ย  โ””โ”€โ”€ web_profiler.yml
โ”‚
โ”œโ”€โ”€ config_prod
โ”‚ย ย  โ”œโ”€โ”€ doctrine.yml
โ”‚ย ย  โ”œโ”€โ”€ framework.yml
โ”‚ย ย  โ””โ”€โ”€ monolog.yml
โ”‚
โ”œโ”€โ”€ config_test
โ”‚ย ย  โ”œโ”€โ”€ framework.yml
โ”‚ย ย  โ”œโ”€โ”€ swiftmailer.yml
โ”‚ย ย  โ””โ”€โ”€ web_profiler.yml
โ”‚
โ”œโ”€โ”€ config_dev.yml
โ”œโ”€โ”€ config_prod.yml
โ”œโ”€โ”€ config_test.yml
โ”œโ”€โ”€ config.yml
โ”‚
โ”‚   # parameters.yml, routing.yml, security.yml etc. will never be touched
โ”œโ”€โ”€ parameters.yml
โ”œโ”€โ”€ parameters.yml.dist
โ”œโ”€โ”€ routing_dev.yml
โ”œโ”€โ”€ routing.yml
โ”œโ”€โ”€ security.yml
โ””โ”€โ”€ services.yml

The cleaned up config.yml looks like this:, (*4)

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: config/assetic.yml }
    - { resource: config/doctrine.yml }
    - { resource: config/framework.yml }
    - { resource: config/parameters.yml }
    - { resource: config/swiftmailer.yml }
    - { resource: config/twig.yml }

config_dev.yml content:, (*5)

imports:
    - { resource: config.yml }
    - { resource: config_dev/assetic.yml }
    - { resource: config_dev/framework.yml }
    - { resource: config_dev/monolog.yml }
    - { resource: config_dev/swiftmailer.yml }
    - { resource: config_dev/web_profiler.yml }

Advantages:

  • Keep an overview which config modules are present by just looking at the sub folders
  • By keeping separate files in your git repository, you may easily follow changes for specific config sections
  • Working in larger teams becomes a little easier when the main config.yml isn't edited by several people at once
  • The configuration sections are copied as YAML text, not array data, so all your comments and formatting are preserved!
  • Manipulating specific config sections programmatically becomes a little easier

Installation

Require c33s/symfony-config-manipulator-bundle in your composer.json file:, (*6)

{
    "require": {
        "c33s/symfony-config-manipulator-bundle": "@stable",
    }
}

or, if you are using 'composer-yaml':, (*7)

require:
    c33s/symfony-config-manipulator-bundle:     '@stable'

Register the bundle in app/AppKernel.php:, (*8)


// app/AppKernel.php public function registerBundles() { return array( // ... existing bundles new C33s\SymfonyConfigManipulatorBundle\C33sSymfonyConfigManipulatorBundle(), ); }

Usage

All you have to do is run a single command:, (*9)

$ php app/console config:refresh-files

You may re-run it anytime you want. This is especially helpful if you are adding new configuration sections to your project. Just paste them into your main config.yml, config_dev.yml or similar files and run the command to instantly move the new configuration to separate files., (*10)

If you add a config section to your config.yml that is already present in a separate file with the same name, the command will exit with an error message. Merge your configurations manually and you're good again., (*11)

Safety

The config splitter will never overwrite any existing module config files as long as they contain parseable YAML. But as Murphy's law goes, there might be bugs where nobody expects them., (*12)

Make sure to commit your configuration files to your git repository to keep your code safe!, (*13)

The Versions

20/06 2016

dev-master

9999999-dev https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

20/06 2016

v0.3.0

0.3.0.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

04/01 2016

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

06/12 2015

v0.2.2

0.2.2.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2015

v0.2.1

0.2.1.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

05/12 2015

v0.2.0

0.2.0.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

07/09 2015

v0.1.1

0.1.1.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires

22/08 2015

v0.1.0

0.1.0.0 https://github.com/vworldat/C33sSymfonyConfigManipulatorBundle

Utilities to automatically organize Symfony2 YAML config files

  Sources   Download

MIT

The Requires

 

The Development Requires