wilkques/config

v3.0.2 2024-06-11 06:08 UTC

This package is auto-updated.

Last update: 2024-09-11 06:38:59 UTC


README

TESTS Latest Stable Version License

composer require wilkques/config

如何使用

  1. 添加PHP配置文件(路径默认 ./Config

    <?php
    
    return [
        'abc' => 'efg',
    ];

    或者json格式

    {
        "abc": "efg",
    }

    或者yaml格式
    ※需要PHP yaml扩展

    abc:
        efg: "hij"
  2. 在文件中添加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