patlabs / sulu-configuration-bundle
A Sulu bundle for managing dynamic configuration settings through the admin interface with form-based configuration storage and retrieval
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.1
- sulu/sulu: ^2.6
Requires (Dev)
- jackalope/jackalope-doctrine-dbal: ^1.3.4 || ^2.0
- jangregor/phpstan-prophecy: ^1.0
- php-cs-fixer/shim: ^3.58
- phpspec/prophecy: ^1.15
- phpstan/phpstan: ^1.9
- phpstan/phpstan-doctrine: ^1.2
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-symfony: ^1.1
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^8.4
- symfony/browser-kit: ^4.3 || ^5.0 || ^6.0 || ^7.0
- symfony/dotenv: ^4.4 || ^5.0 || ^6.0
- thecodingmachine/phpstan-strict-rules: ^1.0
README
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.
📦 Requirements
- Sulu CMS >= 2.6
🚀 Features
- 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
🛠️ Installation
composer require patlabs/sulu-configuration-bundle
Then 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 --force
🛠️ Configuration
To 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)
🔤️ Admin UI
The bundle integrates seamlessly into the Sulu Admin Interface and allows:
- Editing of all defined configurations
- Validation of inputs
💡 Usage in Code
// Controller $siteTitle = $this->get(\PatLabs\SuluConfigurationBundle\Services\ConfigService::class)->getConfig('configKey.fieldName');
Or in Twig:
{{ sulu_config('configKey.fieldName') }}
Made with ❤️ for Sulu Developers