Custom

Custom hooks may be created and invoked in a Slim application. When a custom hook is invoked with applyHook(), it willinvoke all callables assigned to that hook. This is exactly how the Slim application’s default hooks work. In thisexample, I apply a custom hook called “my.hook.name”. All callables previously registered for this hook will be invoked.

  1. <?php
  2. $app = new \Slim\Slim();
  3. $app->applyHook('my.hook.name');

When you run the above code, any callables previously assigned to the hook “my.hook.name” will be invoked in order ofpriority (ascending).

You should register callables to a hook before the hook is applied. Think of it this way: when you invoke the Slimapplication’s applyHook() method, you are asking Slim to invoke all callables already registered for that hook name.