Kohana: under the hood (Bootstrap)

The bootstrap file found under system/core/Bootstrap.php executes the actual Kohana application. It includes the Core files every request runs on.

It starts of with defining some constants such as the version name of Kohana but also whether Kohana runs on Windows. First included file is the core/Benchmark.php which does the benchmarking for Kohana. Directly after, the first benchmark is started and various benchmarks follow. All benchmarks in Kohana can be seen when you add a simple ‘new Profiler;’ to your controller.

Next is the inclusion of some key files in the core directory:

  • utf8.php - so Kohana can use utf8-safe methods to handle strings.
  • Config.php - loads the class which handles configuration items
  • Log.php - does the logging of errors, debug messages or informational messages
  • Event.php - enables the use of events in Kohana. You can register your own but Kohana also employs them.
  • Kohana.php - fires up the controllers, and a lot more

Next is ‘Kohana::setup()’ where a lot is happening which I’ll discuss in the next post. Important to point out is that it attaches some methods to events. The remainder of the bootstrap file is therefore concerned with some benchmarks and events being run.

The following events are executed:

  • system.ready
  • system.routing
  • system.execute
  • system.shutdown

What exactly happens will be covered in the next post in this series.

Leave a Comment