Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include files in Codeigniter

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

like image 530
Mark Fischer Avatar asked Nov 27 '10 16:11

Mark Fischer


People also ask

HOW include external php file in codeigniter?

Then in the middle of the file edit the two variables $application_folder and $system_path and make sure you're using an absolute path instead of a relative one. Then in your external PHP script just include the external. php file and use the $CI global object to access the whole codeigniter: include '../../external.

How to include view file in another view file in codeigniter?

Load a nested view inside the controllerLoad the view in advance and pass to the other view. First put this in the controller: <? php // the "TRUE" argument tells it to return the content, rather than display it immediately $data['menu'] = $this->load->view('menu', NULL, TRUE); $this->load->view ('home', $data); ?>

What is file helper in codeigniter?

The File Helper file contains functions that assist in working with files. Loading this Helper. Available Functions.


2 Answers

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.

like image 74
timdream Avatar answered Sep 27 '22 17:09

timdream


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.

like image 40
Brad Avatar answered Sep 27 '22 19:09

Brad