问题
I am building an admin panel, so I need to make some core settings (like smtp settings, etc) of my Laravel 5 app configurable to end users through front-end interface.
My initial thoughts were to use database as a settings storage alongside caching(to avoid issuing database calls every time a config value is accessed). However, it appears, that Facades are loaded after config files, thus the code below doesn't work:
<?php
// app/config/custom_settings.php
return [
'key' => Cache::get('key');
];
Because of this, I am thinking about writing the user's configuration directly into .env file programmatically. Is this a good idea, or can it turn into a headache in the future?
回答1:
Why don't you store it in your database, in the user's table or in another related table?
I think the .env file is for global settings (database, mail config, cache config,...) but it has not thought to store end user configs.
来源:https://stackoverflow.com/questions/38673236/is-it-a-good-idea-to-edit-env-dynamically-in-laravel-5