About codeiniters structure


I appreciate if anyone can explain a bit about how a page loads with CI framewrok. For example something like this:

1 - All required libraries, helpers,...load
2 - Required controllers load
3 - Required Models load
4 - Required views load

Or did I get it totally wrong? What did I miss?


[eluser]Florian Müller[/eluser]
It actually works in about this order. Point 1 with libraries, helpers, etc. could be specified more detailed, but this I also do not know.

With Models, it's a bit more complicated. You can also specify models in your autoload.php so they will get loaded before any controllers. If autoloading succeeded, the called controller will be loaded and this one can load more stuff like views or models ($this->load->view() / $this->load->model()). I'm sure you also saw CodeIgniters Loader-Class documentation.

Regards, Florian

The best way to get the flow of a page load is to open file index.php and just follow the lines. These are extremely well documented for the first few files doing some magic. Plus, it's a little more complex than you wrote up there - there are a lot of classes loaded prior to the actual processing of what a controller wants to do Wink

I have found somewhere the CI loading steps.


1) Defines the CI version - CI_VERSION
2) Defines the CI Core - FALSE
3) Loads the global functions - core/Common.php
4) Loads the constants - ./application/config/environment/constants.php
OR Loads the Constants - ./application/config/constants.php
5) Defines the custom error handler - _exception_handler
6) Sets the subclass_prefix MY_
7) Sets a liberal script execution time limit
8) Starts the start timer
9) Instantiates the Core Hooks Class
10) Instantiates the pre system hook
11) Instantiates the Core Config Class
12) Instantiates the Core Utf8 Class
13) Instantiates the Core URI class
14) Instantiates the Core Router Class
15) Instantiates the Core Output Class
16) Checks for a valid cache file
17) Instantiates the Core Security Class
18) Instantiates the Core Input Class
19) Instantiates the Core Lang Class
20) Instantiates the Core Controller Class and ./application/core/MY_Controller
21) Instantiates the Application Controllers ./application/controllers
22) Security check for _Private functions
23) Instantiates the pre_controller hook
24) Instantiates the requested controller
25) Instantiates the post controller constructor hook
26) Instantiates the requested method
27) Instantiates the post controller hook
28) Sends final rendered output to the browser
29) Instantiates the post system hook
30) Closes the database connection

Dunno who wrote that, but there's a lot of times where "instantiates" is not the proper word. All of the hook occurrences are method calls. #20 and #21 are file includes. #26 is a method call.

I wrote it and thats the way the comments explain it, but it's written for the old version of CI.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.