我正在寻找一种方法来编写laravel 5配置文件,然后使用更好的旧str_replace
更清晰,更简单的方式。
有laravel 4解决方案: How to edit and save custom config files in Laravel? 和: https://github.com/daftspunk/laravel-config-writer
但这不适用于laravel 5。
答案 0 :(得分:0)
从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);