简体   繁体   English

写入 Laravel 5 配置文件

[英]Write to laravel 5 config files

I'm looking for a way to write to laravel 5 configuration files, in a cleaner and easier way then using the good old str_replace .我正在寻找一种写入 laravel 5 配置文件的方法,比使用旧的str_replace更简洁、更简单。

There are laravel 4 solutions: How to edit and save custom config files in Laravel? Laravel 有 4 种解决方案: 如何在 Laravel 中编辑和保存自定义配置文件? and: https://github.com/daftspunk/laravel-config-writer和: https : //github.com/daftspunk/laravel-config-writer

But this is not working in laravel 5.但这在laravel 5中不起作用。

From version 5.1 you are able to do next for changing any config file:从 5.1 版开始,您可以下一步更改任何配置文件:

config(['YOUR-CONFIG.YOUR_KEY' => 'NEW_VALUE']);
$text = '<?php return ' . var_export(config('YOUR-CONFIG'), true) . ';';
file_put_contents(config_path('YOUR-CONFIG.php'), $text);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM