The idea now is to read it as a file and then modify it, but I don't know how to go about it.
In addition, what is the more elegant way? Or are there any ready-made packages available?
ADD:
I mean, like I have a module in the background of the system is the system setup, how can I write a configuration option from request or elsewhere to a specified file, such as config/app.php. Is there any better way or ready-made package recommendations?
Reply content:
The idea now is to read it as a file and then modify it, but I don't know how to go about it.
In addition, what is the more elegant way? Or are there any ready-made packages available?
ADD:
I mean, like I have a module in the background of the system is the system setup, how can I write a configuration option from request or elsewhere to a specified file, such as config/app.php. Is there any better way or ready-made package recommendations?
To have no contact with similar to such a library, but can provide a train of thought, I think the landlord means to join a strategy, and the background can be configured, when the request comes over, priority to check or load this configuration, I don't know if your controller has such a class design, if you use more than Laravel5, all your controllers are inherited from the controller
class UserController extends Controller{}
My advice is to add a base class in the middle, say Basecontroller, and your controller inherits from Basecontroller.
class BaseController extends Controller{}class UserController extends BaseController{}
At this point, you can add the configuration policy that you want to check or load in Basecontroller (either construct () or any other custom function).
Hope to solve your problem.
This configuration, which requires frequent modifications, can be placed in a database or cache, such as Memcache and Redis.
However, the idea is to provide a file that writes to Laravel config:
Laravel The following configuration file basically is an array of return, you can use this method to get the PHP syntax of the array string:
ob_start();var_export(['abc' => 'efc']);$arrStr = ob_get_contents();ob_end_clean();$config = '
不过这样始终不太安全,建议真要写入文件的话还是用json做配置吧