deskti/laravel-config-writer

1.0.5 2018-03-31 18:02 UTC

This package is not auto-updated.

Last update: 2024-09-23 12:50:55 UTC


README

写入Laravel配置文件并保持文件完整性。

这个库是Laravel使用的Config组件的扩展。它增加了写入配置文件的能力。

您可以在保持文件完整性、保留注释和高级设置的同时,重写基本配置文件(如Laravel配置文件)中的数组值。

支持以下值类型进行写入:字符串、整数、布尔值和一维数组。

使用说明

将以下内容添加到app/config/app.php中的'providers'键下

'October\Rain\Config\ConfigServiceProvider',

现在您可以写入配置文件了

Config::write('app.url', 'http://octobercms.com');

Laravel之外的使用

Rewrite类可以在任何地方使用。

$writeConfig = new October\Rain\Config\Rewrite;
$writeConfig->toFile('path/to/config.php', [
    'item' => 'new value',
    'nested.config.item' => 'value',
    'arrayItem' => ['Single', 'Level', 'Array', 'Values'],
    'numberItem' => 3,
    'booleanItem' => true
]);