ahmad05
ahmad05

Reputation: 458

Where to Place/Manage files in CodeIgniter

My question is When i create class My_loader extends CI_Loader

why there is a need to place it in a folder application/core Can i place it some other folder?

i am finding difficulties in understanding the flow of CodeIgniter how the classes are loaded automatically from the right diretories by just writting this line $this->load->function()

i hope i made my question clear
Please any help will be great PS: i am a newbie at any framework so pardon my question and english if you thinks its a amateur

Upvotes: 0

Views: 361

Answers (2)

Vibin TV
Vibin TV

Reputation: 832

You can see an application folder and a system folder in codeigniter.

System folder contains the files of codeigniter which is the necessary files of codeigniter to function and is not recommended to change these files.

Application folder is for you. You can add your own controllers, views, models, libraries, helpers etc.. there. If you want add some functionality to codeigniter base classes u can do it by creating the corresponding file in application folder. for example if u want to add some functionality to codeiniter security class (which is found in system/core/Security.php) you can do it without changing system files by creating My_security.php in application/core/ directory.

Codeigniter has a well planned directory structure. u can see codeigniter libraries in system/libraries/ and like that your libraries are placed in application/libraries/

U can see the request flow of codeigniter from http://ellislab.com/codeigniter/user-guide/overview/appflow.html

Codeigniter has a very good documentation (goto http://ellislab.com/codeigniter/user-guide)

Upvotes: 1

mamdouh alramadan
mamdouh alramadan

Reputation: 8528

Every time CodeIgniter runs there are several base classes that are initialized automatically as part of the core framework. It is possible, however, to swap any of the core system classes with your own versions or even extend the core versions.

Most users will never have any need to do this, but the option to replace or extend them does exist for those who would like to significantly alter the CodeIgniter core.

Note: Messing with a core system class has a lot of implications, so make sure you know what you are doing before attempting it. from codeigniter user guide

Now what you need to know is that codeigniter uses a Factory to generate its classes, at post-system running phase, and you can take a look into the workflow in /system/core/Codeigniter.php file

and by $this->load->..... this is called an autoloader, and here is a good explanation about it.

Another important note to be taken is:

CodeIgniter does not apply the rules of MVC but it uses a FrontController Pattern so just to take it in mind that it when you are learning codeigniter you are far away from MVC

Upvotes: 1

Related Questions