Description of libraries, helpers, and hooks files in the CI framework

Source: Internet
Author: User
1. if you want to extend the CI function in the library folder, place your class library here. Note that this folder is composed of classes. you can check the notes for loading the library! 2. helper folder if you need to use

1. library folder

If you want to extend the CI function, place your class library here. Note that this folder is composed of classes. you can see the notes for loading the library!

2. helper folder

If you need to use some functions to complete some small functions, put them here. here we use procedural code rather than classes. generally, helper is used for view,

The usage is as follows:

$ This-> load-> helper ('Filename')

FilenameIs the name of the file corresponding to the auxiliary function, not including_ Helper. phpExtension. The file name should be saved as: filename_helper.php, put in the helper folder!

3. hooks folder

Store the hooks you have created. Hooks are the control methods used to load other files and cannot be called by controllers. they are automatically called by the system. After CodeIgniter runs, it generates a special process. Of course, you can customize some actions to replace some stages of the program running. For example, you can trigger your script before or after the controller is loaded, or at other times.

Seven CI mount points:


  • Pre_system
    Early calls of system Execution. no route or other processes are executed only when the benchmark and hooks classes are loaded.
  • Pre_controller
    Call before calling any of your controllers. The basic class, route selection, and security check used at this time have been completed.
  • Post_controller_constructor
    After your controller is instantiated, it is called before any method is called.
  • Post_controller
    It is called after your controller is fully running.
  • Display_override
    Overwrite_ Display ()Function to send the final page to the web browser at the end of the system execution. This allows you to display the page in your own way.$ This-> CI = & get_instance ()Reference the CI super object, and then such final data can be called$ This-> CI-> output-> get_output ().
  • Cache_override
    You can call your own functions to replace_ Display_cache ()Function. This allows you to use your own cache display method.
  • Post_system
    After the final coloring page is sent to the browser, the browser receives the final data and calls

The following describes how to use hooks:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.