fg/config-bundle
Composer 安装命令:
composer require fg/config-bundle
包简介
Settings from db
关键字:
README 文档
README
This bundle helps you to store your settings for application layer. This settings are stored based on scope such as general, user groups, user and can be accessedfrom any layer later.
An example:
Let say we have 30 quota available for Math class:
{
"id": 1,
"scope_group_type": "labs",
"scope_by_id": 2,
"section": "registration",
"name": "quota",
"value": 30,
"created_at" : "2015-08-13 00:00:00",
"updated_at" : "2015-08-13 00:00:00"
}
- Installation
1.1 Install Repository
You can install via composer.
composer require fg/config-bundle
or add to require section of composer.json:
"fg/config-bundle": "dev-master"
1.2 Enable Bundle in app/AppKernel.php
public function registerBundles() { $bundles = array( // ... new Fg\Bundle\ConfigBundle\FgConfigBundle() ); // ... }
1.3 Run migration
php app/console doctrine:schema:update --force
- Usage
2.1 Creating a ne setting
There are three different ways to create a new setting.
2.1.1 By using Command Line Interface (CLI)
You can create a new setting by runnig php app/console fg:config:create command from cli.
2.1.2 By calling create method of SettingService
You can create a new setting by calling the create method of SettingService which previously passed to service container.
$settingService = $this->get('fg_config.service.setting_service'); #create($name, $value, $scopeGroupType, $section, $scopeById = 0) $setting = $settingService->create('test', 'test', 'general', 'general')
2.1.3 By using web user interface
http://localhost/path/to/management/setting
2.2 Accessing
2.2.1 Accessing from controller layer
... $settingService = $this->get('fg_config.service.setting_service'); $settingObject = $settingService->getAllSettingByScope('quota', 'labs', 'registration', 2); ...
2.2.2 Accessing from Twig
...
{{ get_setting('phone') }} //get setting object of name phone
{{ get_setting_value('phone') }} //get value of name phone
...
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-14