CodeIgniter Forums
best practice to handle global variables stored in the database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: best practice to handle global variables stored in the database (/showthread.php?tid=78614)



best practice to handle global variables stored in the database - filit - 02-16-2021

Hi,

I would like to create a web application where settings are retrieved from the database. 

I would use the env file, of course,  to get the database connection settings. But only for that.
All other settings would be loaded from the the database, as said.

Why this approach? Mainly to allow clients to manage their settings their own, from the admin panel. And other few reasons...

My question is: what is the best practice to do what I would like to do?
I was thinking something like: create and entity Settings and a model, as well. Tell the controllers to use (and load) this entity.
I am not sure it is the "correct way", though.

Any help/advice would be appreciated.

Thank you very much


RE: best practice to handle global variables stored in the database - filit - 02-17-2021

I have found this: https://forum.codeigniter.com/thread-76758.html


RE: best practice to handle global variables stored in the database - MGatner - 02-20-2021

You might also check out this module: https://github.com/tattersoftware/codeigniter4-settings