wilkques / config
v3.0.2
2024-06-11 06:08 UTC
Requires
- php: >=8.0
- wilkques/php-helper: *
Requires (Dev)
Suggests
- ext-yaml: Required to use the YAML output option
README
composer require wilkques/config
如何使用
-
添加PHP配置文件(路径默认
./Config
)<?php return [ 'abc' => 'efg', ];
或者json格式
{ "abc": "efg", }
或者yaml格式
※需要PHP yaml扩展abc: efg: "hij"
-
在文件中添加PHP代码
require_once 'vendor/autoload.php'; config() //->setPath('<config/path>') custom config path ->build(); $config = config('<key>'); // get config item $config->setItem('<key>', '<value>'); // set config item $config->withConfig([ '<key>' => '<value>' // set config with array ]); $config->getItem('<key>'); // get config item $config->all(); // get config all items