如何在Laravel中编辑和保存自定义配置文件? [英] How to edit and save custom config files in Laravel?

查看:493
本文介绍了如何在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);

这篇关于如何在Laravel中编辑和保存自定义配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆