reliv / rcm-config
扩展ZF2配置功能,并允许更改配置源
1.2.3
2020-06-25 17:27 UTC
Requires (Dev)
- phpunit/phpunit: 5.*
- squizlabs/php_codesniffer: 3.*
README
模块标题
RCM Config
模块描述
扩展ZF2配置功能,并允许更改配置源
- 模型可以按类别编写和注入,以从任何来源获取
- 默认提供ZF2 ConfigModel和Doctine ConfigModel
- 允许在不影响现有代码的情况下更改配置源
- 允许存储配置值的标准
配置示例
<?php // Example of a config array as might be defined in ZF2 config 'Reliv\RcmConfig' => [ 'myCategory' => [ '_DEFAULT' => [ 'myPropertyName1' => 'my value', 'myPropertyName2' => ['my value1', 'my value2'], ], 'myContext' => [ 'myPropertyName1' => 'my value over-ride', ] ] ], // Example of defining a model for a category 'Reliv\RcmConfig\Models' => [ 'myCategory' => \Reliv\RcmConfig\Model\ConfigModel::class, ],
使用示例
<?php /** Using /Zend\ServiceManager/ServiceManager as $serviceLocator */ $configService = $serviceLocator->get(\Reliv\RcmConfig\Service\ConfigService::class); $value = $configService->getValue( 'myCategory', 'myContext', 'myPropertyName1' ); /** Outputs: 'my value over-ride' */ var_dump($value); $value = $configService->getValue( 'myCategory', 'myContext', 'myPropertyName2' ); /** Outputs: ['my value1', 'my value2'] */ var_dump($value); /** Other Methods */ var_dump( 'getList', $cs->getList('myCategory'), 'getAll', $cs->getAll('myCategory', 'myContext'), 'getDefault', $cs->getDefault('myCategory'), 'getListValue', $cs->getListValue('myCategory', 'myPropertyName1'), 'getPrimary', $cs->getPrimary('myCategory', 'myContext') );
项目作者
James Jervis
https://github.com/reliv/rcm-config
版权所有 (c) 2015, Reliv' 国际