tasmaniski / zend-config-helper
v3.0.2
2020-04-09 15:45 UTC
Requires
- php: >=5.6
- laminas/laminas-config: 2.6.*
- laminas/laminas-dependency-plugin: ^1.0
- laminas/laminas-mvc: 3.0.*
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is auto-updated.
Last update: 2020-11-09 10:53:35 UTC
README
IMPORTANT NOTE: If you find this package useful, please click on a star button and let me know, so I will gladly continue with the updates.
Laminas MVC - Config Helper
一个简单小巧的库,用于在所有控制器和视图文件中读取配置数组。
安装
在您的 composer.json 文件中添加
{ "require": { "tasmaniski/laminas-config-helper": "^3.0" } }
运行: composer update
后,您需要注册新模块。在文件 config/application.config.php 中添加
'modules' => array(
'...',
'ConfigHelper'
),
使用
您可以在任何控制器或视图文件(包括layout.phtml)中使用它。首先您需要在任何配置文件(config/autoload/*)中添加键,例如 "key_from_config"。
//read specific key registred in your config file.
$keyFromConfig = $this->configHelp('key_from_config');
// or in new version of PHP
$keyFromConfig = $this->configHelp()->key_from_config;
$keyFromConfig = $this->configHelp()['key_from_config']; // only for 5.4+
// this will read whole config
$config = $this->configHelp(); // return config object Laminas\Config\Config
echo $config->key_from_config;