Is it a good idea to edit .env dynamically in Laravel 5?

房东的猫 提交于 2019-12-11 00:59:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!