Where is the "best practice" place to put include files (inc.php) when using the Codeigniter framework?
Since you are asking for "best practice", let me give you a long answer:
It's depend what is your included file is about. Since you are using a framework, CodeIginter have defined various places for you to place your library, helper, config, template, etc. It's better to stick to what the framework offers or you won't benefit from it.
It's all about the maintainability, the structure of your app, etc. Don't use a framework unless you are intend to understand them. Use library instead if you are only looking to reuse functionality that people have written.
I think as a general rule of thumb only include a file where and when you need it.
in terms of config files you'll want to include these as the very first file at the top of the page. This will ensure that any constants and configuratios are available for the rest of the scripts execution!
Mark, put your include files in the view directory as long as they are html, xhtml, php etc. You can make directory's under the view directory to keep files in as well.
yes u can by include Path Helper
in your controllers file:
$this->load->helper(array('path'));
then load your file using function file()
:
$this->load->file('your_folder/your_file.php');
Note that your_file.php
file is in root directory in your_folder
dir.