larapack/config-writer

此包已被弃用且不再维护。未建议替代包。

在脚本中将更改保存到配置文件。

安装次数: 107,449

依赖者: 26

推荐者: 0

安全性: 0

星标: 40

关注者: 5

分叉: 13

开放问题: 10

类型:package

v1.0.1 2016-04-28 12:45 UTC

This package is auto-updated.

Last update: 2023-06-20 15:21:42 UTC


README

在脚本中将更改保存到配置文件。

安装

使用Composer安装:composer require larapack/config-writer 1.*

使用它的外观

您可以使用我们的外观 Larapack\ConfigWriter\Facadewrite-方法添加到默认的 Config-外观。

为此,您必须打开您的配置文件 config/app.php 并将 providers-部分的 'Config' => 'Illuminate\Support\Facades\Config::class', 替换为我们的外观 Larapack\ConfigWriter\Facade::class。然后它将看起来像 'Config' => 'Larapack\ConfigWriter\Facade::class',

完成此操作后,您可以使用 Config::write($configFile, $changes),例如,通过以下方式更改您的应用程序URL:Config::write('app', ['url' => 'http://your-site.com'])

使用仓库

您还可以使用仓库 Larapack\ConfigWriter\Repository,它的工作方式类似于模型。

示例

$config = new Larapack\ConfigWriter\Repository('app'); // loading the config from config/app.php

$config->set('debug', false); // set the config you wish

if ($config->get('url') == 'https://#') // you can even get config from this
{
	$config->set('debug', true);
}

$config->save(); // save those settings to the config file once done editing

如果您经常这样做,我建议在配置文件 config/app.phpalias-部分下添加别名 'ConfigWriter' => Larapack\ConfigWriter\Repository::class