Skip to content

Kirby 4.1.2

route:after

/site/config/config.php
return [
    'hooks' => [
        'route:after' => function (Kirby\Http\Route $route, string $path, string $method, mixed $result, bool $final) {
            // your code goes here
            return $result;
        }
    ]
]

Parameters

Parameter Type
$route Kirby\Http\Route
$path string
$method string
$result mixed
$final bool

The $final argument tells you whether the specific route was used by the router (in which case $final is true) or skipped because the route called $this->next() (in which case $final is false).

When is the hook triggered

  • Kirby is set up
  • The routes are loaded
  • The router is created
  • The router tries to find a matching route
  • The route:before hook is triggered
  • The route action is executed
  • Within the route the route action is executed (a page rendered, deleted, or whatever the script does)
  • The route:after hook is triggered with the result of the route action