aamant/config-bundle

Symfony ConfigBundle

0.0.1 2017-04-17 09:40 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:28:59 UTC


README

安装

使用composer安装

composer require aamant/config-bundle

修改AppKernel.php

$bundles = [
    ...
    new Aamant\ConfigBundle\AamantConfigBundle(),
    ...
];

添加路由

aamant_config_config:
    prefix: /config
    resource: "@AamantConfigBundle/Resources/config/routing.xml"

使用服务

$service = $this->getContainer()->get('aamant_config.config');

使用add、get、has、delete

$config->set('version', '0.0.1')
// hidden attribute
$config->set('version', '0.0.1', true)
// get
$config->get('version')
// has
$config->has('version')
// delete
$config->delete('version')

翻译

使用config域来翻译属性的名称

管理属性值

http://my-app/app_dev.php/config