rogerthomas84 / php-config-dot-notation
使用点符号与配置交互
1.0.1
2021-02-05 13:31 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-13 14:48:53 UTC
README
使用点符号从数组获取和设置配置。
用法
创建配置
<?php $config = [ 'app' => [ 'name' => 'Foo Bar', 'version' => 1 ] ]; \ConfigDot\Config::setConfig($config);
获取值
<?php // set the config as above $appName = \ConfigDot\Config::get('app.name'); // $appName = string(7) "Foo Bar" (or null if it does not exist)
检查值是否存在
<?php // set the config as above if (\ConfigDot\Config::has('app.name')) { // it does! }
设置新的配置值
设置新的配置值不会消除原始值,但优先级顺序将决定新值将从 get
请求中返回。
<?php // set the config as above \ConfigDot\Config::update('app.name', 'Wolf');