This is documentation for Kohana v2.3.x.

Table of Contents
StatusStub
TodoWhat events are, how events work, running, adding, using custom
TodoMove stuff from core:event

Events

See Event for information on adding, running, removing and using custom events.

Kohana events consist of a name and callback. Names usually include a prefix with the name 1), but are not required to. All of the core events are prefixed as system.name.

System Events

The following events are defined in the Kohana core files. The pre-defined actions for these events are added in Kohana::setup.

system.ready

Called immediately after hooks are loaded. This is the earliest attachable event. Nothing is attached to this event by default. Hooks are loaded before this point.

system.routing

Processes the URL and does routing. Calls Router::find_uri and Router::setup by default.

system.execute

Controller locating and initialization. A controller object will be created, as an instance of Kohana. Calls Kohana::instance by default.

system.post_routing

Triggered after all routing is done so interventions in routing can be done here. If Router::$controller is empty after this event a 404 is triggered.

system.404

Called when a page cannot be found. Calls Kohana::show_404 by default.

system.pre_controller

Called within system.execute, after the controller file is loaded, but before an object is created.

system.post_controller_constructor

Called within system.execute, after the controller constructor has been called. Kohana::instance will return the controller at this point, and views can be loaded. Controller methods have not been called yet.

system.post_controller

Called within system.execute, after the controller object is created. Kohana::instance will return the controller at this point, and views can be loaded.

system.send_headers

Called just before the global output buffer is closed, before any content is displayed. Writing cookies is not possible after this point, and Session data will not be saved.

system.display

Displays the output that Kohana has generated. Views can be loaded, but headers have already been sent. The rendered output can be manipulated as Event::$data.

system.shutdown

Last event to run, just before PHP starts to shut down. Runs the Kohana::shutdown method by default.

system.log

Called within Kohana::log, useful if you want to send an email when certain events are logged or store log messages in a different location.

system.redirect

Called within url::redirect, useful to detect that the system is about to perform a redirect.

Events Sequence

Hooks

Hooks are included early in Kohana and can be used, e.g., to execute code before controllers are loaded so you can check for authentication early on in processing and thereby reduce server resources. Events and hooks go hand in hand: hooks allow you to attach code to events. See for more information the Hooks page.

1) An example of a “prefix” is prefix.name