Making your own configuration files and using the settings
It's a great idea to have configuration settings in the same file—the benefits are obvious—so rather than having settings hidden in controllers, modules, helpers, libraries, or (God forbid) in views, you can put them in one location and refer to them from there. CodeIgniter comes with its own configuration files in the config
folder; however, you can add your own files to the config
folder and refer to them in your code. It's pretty handy and easy to do; let's take a look.
How to do it...
We're going to create the following two files:
/path/to/codeigniter/application/controllers/config_settings.php
/path/to/codeigniter/application/config/my_config_file.php
- Create the
config_settings.php
controller, ...
Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.