How CodeIgniter 2 works

index.php

  • check system and application folders exist
  • system/core/CodeIgniter.php

system/core/CodeIgniter.php

  • Common.php (libray of basic functions)
  • Hooks.php (ability to handle hooks)
  • hook: pre_system
  • Config.php (load application/config/config.php, init base_url)
  • Utf8.php
  • URI.php
  • Router.php
  • $RTR->_set_routing(): load application/config/routes.php, try to match URI to a route, set class and method (to be used later)
  • Output.php
  • hook: cache_override
  • if hook not set and cache exists, display cache and exit here
  • Security.php
  • Input.php
  • Lang.php
  • Controller.php
    • Loader.php
    • load “autoload” items (libraries, helpers..)
    • define get_instance()
  • application/core/MY_Controller.php (if it exists)
  • load controller class (display 404 if needed)
  • hook: pre_controller
  • create instance of controller
  • hook: post_controller_constructor
  • call controller method _remap() if defined
  • if _remap is not defined, look for method, display 404 if not found
  • call method (with arguments)
  • hook: post_controller
  • hook: display_override
  • if hook not set, generate output, create cache file if needed, send HTTP response (headers + body)
  • hook: post_system
  • close any database connection

Feedback

Great!!

Aug 19, 2012
#1
Bravo!!
Kule
Aug 24, 2012
#2
Genius, thanks.
David
Sep 19, 2012
#3