php - How to Conditionally Load Configuration Files Within CodeIgniter? -


I need to create something similar to the following in my CodeIgniter project: -

  • < Code> my_config.php
  • config_production.php
  • config_development.php

Now, my_config.php will be automatically loaded. From there, if this is a production server, then config_production.php will be loaded; config_development.php will be loaded.

How should I go about executing it?

I have tried to my_config in the following PHP :

  & lt ;? Php if (gethostbyaddr ("127.0.0.1") == 'Hello soba') {$ this-> Config- & gt; Load ('config_production'); } And {$ this- & gt; Config- & gt; Load ('config_development'); }? & Gt; It is not working as   

It has not been initiated as $ this-> config . How can I get it?

Two options: You can try referencing the object instead of "$ CI" "$ This "of:

  $ CI = & amp; get Instance(); // Do this once in this file $ CI- & gt; Config- & gt; Load (); $ CI- & gt; Whatever;  

... which is the correct way of referencing the CI object from outside.

Or second, you can switch configs from within your config.php file:

   

... etc .. Load all the differences between two / if block.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -