PHPackages                             craue/config-bundle - 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. craue/config-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

craue/config-bundle
===================

Database-stored settings made available via a service for your Symfony project.

2.7.0(2y ago)1771.0M↓25.6%34[9 issues](https://github.com/craue/CraueConfigBundle/issues)[1 PRs](https://github.com/craue/CraueConfigBundle/pulls)4MITPHPPHP ^7.3|^8

Since May 26Pushed 2y ago13 watchersCompare

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

READMEChangelogDependencies (24)Versions (25)Used By (4)

Information
===========

[](#information)

[![Tests](https://github.com/craue/CraueConfigBundle/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/craue/CraueConfigBundle/actions/workflows/tests.yml)[![Coverage Status](https://camo.githubusercontent.com/e95755353bbcedfda520f3371c12f856387ea775b078589ab3dfaef365c81e69/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f63726175652f4372617565436f6e66696742756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/craue/CraueConfigBundle?branch=master)

CraueConfigBundle manages configuration settings stored in the database and makes them accessible via a service in your Symfony project. These settings are similar to those defined in `parameters.yml` but can be modified at runtime, e.g. by an admin user.

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

[](#installation)

Get the bundle
--------------

[](#get-the-bundle)

Let Composer download and install the bundle by running

```
composer require craue/config-bundle
```

in a shell.

Enable the bundle
-----------------

[](#enable-the-bundle)

If you don't use Symfony Flex, register the bundle manually:

```
// in config/bundles.php
return [
	// ...
	Craue\ConfigBundle\CraueConfigBundle::class => ['all' => true],
];
```

Create the table
----------------

[](#create-the-table)

Preferably you do this by calling

```
# in a shell
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
```

or

```
# in a shell
php bin/console doctrine:schema:update
```

or however you like.

Add the route to manage settings (optional)
-------------------------------------------

[](#add-the-route-to-manage-settings-optional)

You can either import the default routing configuration

```
# in app/config/routing.yml
craue_config_settings:
  resource: "@CraueConfigBundle/Resources/config/routing/settings.xml"
  prefix: /settings
```

...or add your own to have full control over the URL pattern.

```
# in app/config/routing.yml
craue_config_settings_modify:
  path: /settings/modify
  defaults:
    _controller: Craue\ConfigBundle\Controller\SettingsController::modifyAction
```

Some CSS is needed to render the form correctly. Install the assets in your project:

```
# in a shell
php bin/console assets:install --symlink web
```

Usage
=====

[](#usage)

Defining settings
-----------------

[](#defining-settings)

This bundle does *not* provide functionality to create new settings because this would make no sense at runtime. Those settings will be used in your application and thus code needs to be written for that. This means that you have to create new settings in the database table `craue_config_setting` yourself, e.g. using a migration.

Managing settings' values
-------------------------

[](#managing-settings-values)

If you added the route described above you can manage the values of all defined settings in a simple form. By default, you can access that form by browsing to `/settings/modify`. But you probably want to limit access to this form in your security configuration.

Reading and writing settings
----------------------------

[](#reading-and-writing-settings)

For accessing settings, the bundle provides the service `Craue\ConfigBundle\Util\Config`. To use it directly in a controller, either add an autowired type-hinted argument to the action...

```
// in src/Controller/MyController.php
use Craue\ConfigBundle\Util\Config;

public function indexAction(Config $config) {
	// use $config
}
```

...or let your controller extend `Symfony\Bundle\FrameworkBundle\Controller\AbstractController` and make the service alias `craue_config` available by defining `getSubscribedServices`:

```
// in src/Controller/MyController.php
use Craue\ConfigBundle\Util\Config;

public function indexAction() {
	// use $this->get('craue_config')
}

public static function getSubscribedServices() {
	return array_merge(parent::getSubscribedServices(), [
		'craue_config' => Config::class,
	]);
}
```

The service defines the following methods:

- `all()` - get an associative array of all defined settings and their values
- `get($name)` - get the value of the specified setting
- `getBySection($section)` - like `all()`, but get only settings within the specified section (or those without a section if explicitly passing `null`)
- `set($name, $value)` - set the value of the specified setting
- `setMultiple([$name1 => $value1, $name2 => $value2])` - set values for multiple settings at once

Keep in mind that each setting has to be present, or an exception will be thrown.

Usage in Twig templates
-----------------------

[](#usage-in-twig-templates)

The Twig extension in this bundle supports reading settings directly in your template.

```
{{ craue_setting('name-of-a-setting') }}
```

Enable caching (optional)
=========================

[](#enable-caching-optional)

To reduce the number of database queries, you can set up a cache for settings. First, you have to choose which cache implementation you'd like to use. Currently, there are adapters available for:

- [DoctrineCacheBundle](https://github.com/doctrine/DoctrineCacheBundle)
- [Symfony Cache component](https://symfony.com/doc/current/components/cache.html)

Refer to the documentation of each implementation for details and read on in the corresponding section below. When done, `CraueConfigBundle` will automatically cache settings (using the built-in `craue_config_cache_adapter` service).

Keep in mind to clear the cache (if needed) after modifying settings outside of your app (e.g. by Doctrine migrations):

```
# in a shell
php bin/console doctrine:cache:clear craue_config_cache
```

 Cache implementation: DoctrineCacheBundleSet the parameter `craue_config.cache_adapter.class` appropriately and configure a so-called cache provider with the alias `craue_config_cache_provider`:

```
# in app/config/config.yml
parameters:
  craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\DoctrineCacheBundleAdapter

doctrine_cache:
  providers:
    craue_config_cache:
      apc: ~
      namespace: craue_config
      aliases:
        - craue_config_cache_provider
```

 Cache implementation: Symfony Cache componentSet the parameter `craue_config.cache_adapter.class` appropriately and configure a so-called cache pool with the service id `craue_config_cache_provider`:

```
# in app/config/config.yml
parameters:
  craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\SymfonyCacheComponentAdapter

services:
  craue_config_cache_provider:
    class: Symfony\Component\Cache\Adapter\FilesystemAdapter
    public: false
    arguments:
      - 'craue_config'
      - 0
      - '%kernel.cache_dir%'
```

Customization
=============

[](#customization)

Redirect to a different page after submitting the built-in form
---------------------------------------------------------------

[](#redirect-to-a-different-page-after-submitting-the-built-in-form)

If you've enabled the build-in form, you can define where to redirect on successfully saving the changes by setting the target route name:

```
# in app/config/parameters.yml
parameters:
  craue_config.redirectRouteAfterModify: craue_config_settings_modify
```

Rendering of settings in sections
---------------------------------

[](#rendering-of-settings-in-sections)

If you want to render settings in a group (called section here), you'll have to assign those settings a common section name (in the database). Optionally, you can influence the order of these sections:

```
# in app/config/parameters.yml
parameters:
  craue_config.configTemplate.sectionOrder: [section1, section2, section3]
```

Settings without a section will be rendered at first. Sections without explicit ordering are rendered at last.

Translation
-----------

[](#translation)

You can add translations for all settings (and sections) to be shown in the form by adding them to translation files with the `CraueConfigBundle` domain, e.g.

```
# in app/Resources/CraueConfigBundle/translations/CraueConfigBundle.en.yml
name-of-a-setting: name of the setting

# in app/Resources/CraueConfigBundle/translations/CraueConfigBundle.de.yml
name-of-a-setting: Name der Einstellung
```

Using a custom entity for settings
----------------------------------

[](#using-a-custom-entity-for-settings)

The custom entity has to provide a mapping for the field `value`. The class `BaseSetting` defines this field, but no mapping for it. This allows easy overriding, including the data type. In the following example, the `value` field will be mapped to a `text` column, which will in turn render the built-in form fields as `textarea`.

So create the entity and its appropriate mapping:

```
// src/MyCompany/MyBundle/Entity/MySetting.php
use Craue\ConfigBundle\Entity\BaseSetting;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Craue\ConfigBundle\Repository\SettingRepository")
 * @ORM\Table(name="my_setting")
 */
class MySetting extends BaseSetting {

	/**
	 * @var string|null
	 * @ORM\Column(name="value", type="text", nullable=true)
	 */
	protected $value;

	/**
	 * @var string|null
	 * @ORM\Column(name="comment", type="string", nullable=true)
	 */
	protected $comment;

	public function setComment($comment) {
		$this->comment = $comment;
	}

	public function getComment() {
		return $this->comment;
	}

}
```

And make the bundle aware of it:

```
# in app/config/config.yml
craue_config:
  entity_name: MyCompany\MyBundle\Entity\MySetting
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity56

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 96.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~186 days

Recently: every ~339 days

Total

23

Last Release

1001d ago

Major Versions

1.4.2 → 2.0.02017-05-11

PHP version history (6 changes)1.0.0PHP &gt;=5.3.2

1.4.1PHP ^5.3.2|~7.0

2.0.0PHP ^5.3.9|~7.0

2.2.0PHP ~7.0

2.5.0PHP ^7.3|^8

2.7.x-devPHP ^7.3 || ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/d1634a0daf607752890692d69453ca9137e1021536d6f2a49526175a03409202?d=identicon)[craue](/maintainers/craue)

---

Top Contributors

[![craue](https://avatars.githubusercontent.com/u/800119?v=4)](https://github.com/craue "craue (359 commits)")[![franmomu](https://avatars.githubusercontent.com/u/720690?v=4)](https://github.com/franmomu "franmomu (7 commits)")[![enl](https://avatars.githubusercontent.com/u/670322?v=4)](https://github.com/enl "enl (2 commits)")[![rvanlaak](https://avatars.githubusercontent.com/u/2707563?v=4)](https://github.com/rvanlaak "rvanlaak (2 commits)")[![pmartelletti](https://avatars.githubusercontent.com/u/557390?v=4)](https://github.com/pmartelletti "pmartelletti (1 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (1 commits)")

---

Tags

bundlephpsymfonysymfony-bundlesymfonyconfig

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/craue-config-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/craue-config-bundle/health.svg)](https://phpackages.com/packages/craue-config-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
