Include Files in Codeigniter

Where is the "best practice" place to put include files (inc.php) when using the Codeigniter framework?

+4
source share
4 answers

Since you are asking for β€œbest practice,” let me give you a long answer:

It depends on your included file. . Since you use the framework, CodeIginter defined various places for placing your library, helper, config, template, etc. It’s best to stick to what the frame offers or you won’t benefit from it. All about maintainability, structure of your application, etc. Do not use frames unless you intend to understand them. Use a library instead if you only want to reuse the functionality that people wrote.

+6
source

Note, put your included files in the view directory if they are html, xhtml, php, etc. You can make a directory in the views directory to also save files.

+4
source

yes u can include Path Helper in your controller file:

$ this-> load-> helper (array ('path'));

then upload the file using the file() function:

$ this-> load-> file ('your_folder / your_file.php');

Notice that your_file.php is located in the root directory of your_folder .

+3
source

I think that the general rule contains only the file where and when you need it.

in terms of the configuration files you want to include as the very first file at the top of the page. This will ensure the availability of any constants and configurations for the rest of the scenarios!

+2
source

All Articles