2017 © Pedro Peláez
 

library config-bundle

A Symfony bundle to handle app config

image

itk-dev/config-bundle

A Symfony bundle to handle app config

  • Wednesday, April 4, 2018
  • by rimi-itk
  • Repository
  • 3 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 17 % Grown

The README.md

Settings

Installation

composer require itk-dev/settings-bundle "^1.0"

Enable the bundle in app/AppKernel.php:, (*1)

public function registerBundles() {
    $bundles = [
        // …
        // Start of required dependencies of ItkDevConfigBundle
        new Craue\ConfigBundle\CraueConfigBundle(),
        new EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle(),
        // End of required dependencies for ItkDevConfigBundle
        new ItkDev\ConfigBundle\ItkDevConfigBundle(),
    ];
    // …
}

In app/config/config.yml:, (*2)

craue_config:
    entity_name: ItkDev\ConfigBundle\Entity\Setting

# Optionally, enable caching for craue/config-bundle (cf. https://github.com/craue/CraueConfigBundle/#enable-caching-optional)
services:
  craue_config_cache_provider:
    class: Symfony\Component\Cache\Adapter\FilesystemAdapter
    public: false
    arguments:
      - 'craue_config'
      - 0
      - '%kernel.cache_dir%'

Depending on your doctrine setup, you may have to add ItkDevConfigBundle to your doctrine mappings, e.g.:, (*3)

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    …
                    ItkDevConfigBundle: ~

If using Doctrine migrations, you should filter out the craue_config_setting table from migrations:, (*4)

doctrine:
    dbal:
        [...]
        schema_filter: ~^(?!craue_config_setting)~

Usage

Create settings in the database (preferably using a migration):, (*5)

insert into
    itkdev_setting(section, name, type, form_type, value_string)
values
    ('cms', 'about_header', 'string', 'text', 'About this application');

insert into
    itkdev_setting(section, name, type, form_type, value_text)
values
    ('cms', 'about, 'text', 'text', 'This application handles configuration on the database.);

Easy admin:, (*6)

See Resources/config/easy_admin.yml for an example Easy Admin configuration for Settings., (*7)

Twig:, (*8)

See https://github.com/craue/CraueConfigBundle/#usage-in-twig-templates, (*9)

Rich text

To use the form type ckeditor, you have to enable IvoryCKEditorBundle (which is already installed)., (*10)

Follow steps 2–4 on https://symfony.com/doc/master/bundles/EasyAdminBundle/integration/ivoryckeditorbundle.html#installing-the-rich-text-editor to enable the bundle., (*11)

The Versions