Home >Backend Development >PHP Tutorial >Detailed description of libraries, helpers, hooks folders in CI framework_PHP tutorial
1.library folder
If you want to extend the functions of CI, then put your class library here. Note that this folder is composed of classes. You can take a look at the precautions for loading the library!
2.helper folder
If you need to use some functions to help you complete some small functions, then leave it alone. These are procedural codes instead of classes. Generally, helpers are used for views.
The usage method is as follows:
filename is the file name corresponding to the helper function, excluding the _helper.php extension. The file name should be saved as: filename_helper.php and placed in the helper folder!
3.hooks folder
Store the hook you created. Hooks are control methods used to load other files. They cannot be called by controllers, etc. They are automatically called by the system. When CodeIgniter
is run, it will spawn a special process.
Of course, you can customize some actions to replace certain stages during the running of the program. For example, you can run a specific script just before or just after the controller loads, or trigger your script at other times.
Seven mount points for CI:
pre_system
Early call executed by the system. Only when the benchmark and hooks classes are loaded. No routing or other processes are executed.
pre_controller
Called before any of your controllers are called. At this point the base classes, routing and security checks used are complete.
post_controller_constructor
Called after your controller is instantiated and before any method calls.
post_controller
Called after your controller is fully running.
display_override
Override the _display() function, which is used to send the final page to the web browser at the end of system execution. This allows you to display it in your own way. Note that you need to pass $this->CI =& get_instance() Reference to the CI super object, then such final data can be obtained by calling $this->CI->output->get_output().
cache_override
Allows you to call your own function to replace the _display_cache() function in the output class. This allows you to use your own cache display method
post_system
After the final coloring page is sent to the browser, the system execution end call after the browser has received the final data
Regarding the use of hooks, there are detailed instructions in the manual, and the screenshot is as follows: