2

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?

miken32
  • 42,008
  • 16
  • 111
  • 154
Alex Lomia
  • 6,705
  • 12
  • 53
  • 87
  • You should store them as flat files in `storage/app`. You can read them into the Config, overwriting values, or write a config handler. The handler could give you some advantages like validating settings. – Qevo Jul 30 '16 at 21:01

1 Answers1

0

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.

Jesús Amieiro
  • 2,443
  • 21
  • 15
  • I'll update the question to address these issues. However, I need to give user a possibility to tinker with the app-specific configs like smtp and other ones, as I'm building an admin panel. – Alex Lomia Jul 30 '16 at 11:18