Bundles are a way of extending functionality in your Tomahawk App. You could have a bundle for your Frontend and another for your Backend, or even a bundle for sending emails.

Creating Your First Bundle

When you install Tomahawk, it comes with a basic bundle to get you started, with a Controller and View. You can either edit this one or create a new one.

For ease all bundles should go in the src folder. This directory is PSR-4 autoloaded via composer.

Below is the minimum you need to create a Bundle, there are no required methods to implement:

Doing more with your Bundles

There are 3 methods that you will most likely use, boot (When the Bundle boots), shutdown (When the Bundle shutsdown) and getParent (What Bundle to override).

Booting your Bundle

The boot method is used to register any services to setup you bundle or even add event listeners, for example:

Shutting down your Bundle

The shutdown method is used to un-register any services in your bundle or remove event listeners, for example:

Override an existing bundle

The getParent method is used when you want to override the functionality of an existing bundle. You simple return the name of that bundle:

Bundle Routes

From version 1.2.0 of Tomahawk you can now define a path in your bundle to load routes from:

Registering Event Listeners/Subscribers

From version 1.2.0 of Tomahawk you can now register event listener/subscribers. All bundles are loaded at this point giving you access to all services in the container