EllisLab text mark
Advanced Search
     
About codeiniters structure
Posted: 08 November 2012 02:27 AM   [ Ignore ]
Joined: 2012-10-29
127 posts

Hello;

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?

Thanks

 

 
Posted: 09 November 2012 06:49 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2012-11-02
10 posts

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

 Signature 

I’m no signature, I’m just cleaning here…

 
Posted: 09 November 2012 08:28 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

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

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess

 
Posted: 14 November 2012 04:37 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2008-10-14
57 posts

I have found somewhere the CI loading steps.

CodeIgniter.php

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

 
Posted: 14 November 2012 05:05 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

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.

 
Posted: 14 November 2012 06:45 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

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

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View