如何在 Laravel 中编辑和保存自定义配置文件?

我正在 Laravel 4 中创建简单的 Web 应用程序.我有用于管理应用程序内容的后端.作为后端的一部分,我希望有 UI 来管理应用程序设置.我希望我的配置变量存储在文件 [FOLDER: /app/config/customconfig.php] 中.

I am creating simple web application in Laravel 4. I have backend for managing applications content. As a part of backend i want to have UI to manage applications settings. I want my configuration variables to be stored in file [FOLDER: /app/config/customconfig.php].

我想知道 Laravel 中是否有可能拥有自定义配置文件,可以通过后端 UI 进行管理/更新?

I was wondering if there's any possibility in Laravel how to have custom config file, which can be managed/updated thru backend UI?

推荐答案

我是这样做的...

config(['YOURKONFIG.YOURKEY' => 'NEW_VALUE']);
$fp = fopen(base_path() .'/config/YOURKONFIG.php' , 'w');
fwrite($fp, '<?php return ' . var_export(config('YOURKONFIG'), true) . ';');
fclose($fp);

相关文章