Welcome Guest, Not a member yet? Register   Sign In
Hooks
#1

I am new in codeigniter. Can any one help me with hooks and why it's used for ? Thank you.. and I am not sure where to post so, I posted here.
Reply
#2

All information regarding hooks can be found in the userguide.
https://codeigniter.com/user_guide/general/hooks.html

There are ment to be executed before or after "big things" happen.
https://codeigniter.com/user_guide/gener...ook-points

I got three hooks. Load different language, load global constants and check if a user are logged in.
PHP Code:
$hook['post_controller_constructor'] = array(
    
'function' => 'language_loader',
    
'filename' => 'language_loader.php',
    
'filepath' => 'hooks'
);

$hook['pre_system'] = array(
    
'function' => 'auth_constants',
    
'filename' => 'auth_constants.php',
    
'filepath' => 'hooks'
);
$hook['post_system'] = array(
    
'function' => 'auth_sess_check',
    
'filename' => 'auth_sess_check.php',
    
'filepath' => 'hooks'
); 
Reply
#3

(This post was last modified: 01-26-2022, 02:39 AM by jerinho.)

(01-30-2020, 07:05 AM)kamrul6665 Wrote: I am new in codeigniter. Can any one help me with hooks and why it's used for ? Thank you.. and I am not sure where to post so, I posted here.

For certain reason which I'm also still finding out, Codeigniter does not handle errors with try-catch. So if you switch your environment to production, user will see the 'snag' error which you most probably don't want it. In previous version, some functions don't throw error, so you can still check for unexpected result and handle it without a hook. Latest version giving straight crash so you have no chance to check for it. For example when establishing a database connection ($db->conect()). And here comes the hook for the rescue.

Dear moderator, this link is no longer working.
Reply
#4

You have the wrong link.

CodeIgniter 3 Users Guide - Hooks - Extending the Framework Core

You do know that this post is 2 years old right!
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB