Codeigniter: Custom configuration or constant?

I have some global parameter variables that I need to save for my application, but I'm confused about whether I should use my own configuration file or just add new constants to the end of the config / constants.php file? These variables will not change after installation, so are constants the right choice?

What is the difference between them and how does Codeigniter handle them?

+7
source share
1 answer

Custom IMO configuration file. This will make your life easier when you decide to upgrade to the new major version of CI, since you can overwrite config.php without losing critical application constants.

config.php entire application is always loaded, so everything you insert there will be available globally, while custom configuration files can be downloaded on demand, saving resources and providing a better separation of code responsibilities.

Example: loading a configuration file on demand:

 $this->config->load('filename'); 
+8
source

All Articles