CodeIgniter Forums
Load database config from external file. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Load database config from external file. (/showthread.php?tid=82740)



Load database config from external file. - yu pawi - 08-17-2022

Hello,

In the company I work, we developed a webapp based on CI, and my boss wants to "skip" the part when he needs to set the database parameters in CI, because we have already another file in another directory (/etc) where all that information is. So my question is: Is there a way to load that file externally instead of setting the database info in every new install?

Thanks in advance.

Betflik


RE: Load database config from external file. - kenjis - 08-20-2022

Read the file and set the config to environment variables.

> When you instantiate a configuration class, any namespaced environment variables are considered for merging into the configuration object’s properties.
See https://codeigniter4.github.io/CodeIgniter4/general/configuration.html#configuration-classes-and-environment-variables