nwidart/laravel-config-writer

dev-master 2015-04-11 12:11 UTC

This package is auto-updated.

Last update: 2024-09-08 07:04:24 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'
]);