fg/config-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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"
}
  1. 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
  1. 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
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固