itk-dev / config-bundle
用于处理应用程序配置的Symfony包
3.0.0
2019-01-10 16:08 UTC
Requires
- craue/config-bundle: ~2.2
- doctrine/dbal: ^2.5
- easycorp/easyadmin-bundle: ^2.0
- friendsofsymfony/ckeditor-bundle: ^2.0
- symfony/framework-bundle: ~3.0|~4.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.10
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2024-09-19 15:25:16 UTC
README
安装
composer require itk-dev/settings-bundle "^1.0"
在app/AppKernel.php
中启用该包
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(), ]; // … }
在app/config/config.yml
中
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%'
根据您的Doctrine设置,您可能需要将ItkDevConfigBundle
添加到您的Doctrine映射中,例如:
doctrine: orm: entity_managers: default: mappings: … ItkDevConfigBundle: ~
如果您使用Doctrine迁移,则应该从迁移中过滤掉craue_config_setting
表
doctrine: dbal: [...] schema_filter: ~^(?!craue_config_setting)~
使用方法
在数据库中创建设置(最好使用迁移)
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
查看Resources/config/easy_admin.yml以获取设置示例Easy Admin配置。
Twig
请参阅https://github.com/craue/CraueConfigBundle/#usage-in-twig-templates
富文本
要使用表单类型ckeditor
,您必须启用IvoryCKEditorBundle(已安装)。