SuluConfigurationBundle enables easy creation, management and use of custom configurations in Sulu CMS. It provides a flexible structure for defining and maintaining settings via the admin interface or programmatically via Symfony.
- Sulu CMS >= 2.6
- Configuration management via the Sulu admin UI
- Support for all Sulu form fields
- Ability to group and structure settings
- Integration in Twig and controllers via simple service access
composer require patlabs/sulu-configuration-bundleThen register the bundle:
// config/bundles.php
return [
// ...
PatLabs\SuluConfigurationBundle\SuluConfigurationBundle::class => ['all' => true],
];Add the admin routing configuration:
# config/routes/sulu_admin.yaml
...
sulu_config_api:
resource: "@SuluConfigurationBundle/Resources/config/routing_api.yml"
type: rest
prefix: /admin/api
Add the following package configuration:
# config/packages/sulu_configuration.yaml
sulu_configuration:
configurations:
directories:
- '%kernel.project_dir%/config/configs'Create the configs folder: config/configs
In this folder, all desired configurations can be defined. To do this, simply create an XML that defines an Admin Form, as you already know. (https://docs.sulu.io/en/2.6/book/extend-admin.html#form-configuration)
Last but not least, you need to update the database schema:
php bin/console doctrine:schema:update --forceTo add a custom settings panel in the administration, simply create an XML in config/configs that defines an Admin Form, as you already know. (https://docs.sulu.io/en/2.6/book/extend-admin.html#form-configuration)
Also have a look at the example. (https://github.com/patrickpahlke03/SuluConfigurationBundle/tree/main/Resources/example)
The bundle integrates seamlessly into the Sulu Admin Interface and allows:
- Editing of all defined configurations
- Validation of inputs
// Controller
$siteTitle = $this->get(\PatLabs\SuluConfigurationBundle\Services\ConfigService::class)->getConfig('configKey.fieldName');Or in Twig:
{{ sulu_config('configKey.fieldName') }}Made with ❤️ for Sulu Developers