jamalosm/config-writer

配置写入器

该包的规范存储库似乎已消失,因此该包已被冻结。

1.0.0 2019-05-19 16:19 UTC

This package is auto-updated.

Last update: 2022-11-20 00:33:47 UTC


README

安装

composer require jamalosm/config-writer 1.*

用法

// config/app.php
return [
    "name" => 'B-ONE Application',
    "versions" => [
        "v1" => "19.02.2017",
        "v2" => "23.04.2018",
    ]
];
<?php
// index.php
require 'vendor/autoload.php';

$configPath = __DIR__."/config";

$instance = \BONE\Config\Config::getInstance($configPath);

$configWriter = new \BONE\ConfigWriter\ConfigWriter($configPath, $instance);

###方法

write($key, $default = null)

在配置文件中写入配置值。

    $configWriter->write('app.path', 'app/local'); //'app/local'
    
    $instance->get('app.path'); //'app/local'
    
    $instance->get('app');
    /*
    [
        "name" => 'B-ONE Application',
        "versions" => [
            "v1" => "19.02.2017",
            "v2" => "23.04.2018",
        ],
        "path" => "app/local"
    ]
    */

写入前的文件。

// config/app.php
return [
    "name" => 'B-ONE Application',
    "versions" => [
        "v1" => "19.02.2017",
        "v2" => "23.04.2018",
    ],
    "path" => "app/local"
];