I am new to civicrm.
I have created a module; say com.ex.myextention. and created a page its working fine.
But in my module where I have to write a hook and how to ensure the defined hook is working.
CiviCRM Stack Exchange is a question and answer site for administrators and users of the CiviCRM Constituent Relationship Management software. It only takes a minute to sign up.Sign up to join this community
"To implement a hook, add a function to the module's main .php file created earlier with civix generate:module" - the developer guide.
However, if you've created your own page class, you may not need to use a hook at all, since you have complete control of the code.
If I haven't answered your question, please update your question with a bit more detail about what you're trying to do.