axdlee/laravel-config-writer

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

1.0.2 2017-04-20 06:45 UTC

This package is not auto-updated.

Last update: 2024-09-29 00:42:13 UTC


README

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

此库支持 Laravel 5.3+。

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

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

支持的写入值类型包括:字符串、整数、布尔值和单维数组。

使用说明

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

Axdlee\Config\ConfigServiceProvider::class,

现在您可以为配置文件写入内容

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

Laravel 外部使用

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

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