Routing is the main part to any application. Tomahawk makes use of Symfony's poweful Routing Component, as there's no point re-inventing the wheel. You can read more about Symfony Routing here.

Defining Routes

You add routes in the app/Resources/routes.php file.

You define routes using the Tomahawk\Routing\Router class. There should be one instantiated in this file already.

From the example above, the 1st parameter is the path, the 2nd is the name of the route (used by the URL Generator) and the 3rd is the callback.

A callback can be either a closure or string defining the class and method in the following format: Controller::action

Route Parameters

You can define parameters to capture in the URL.

You can also set a default value:

Declaring parameter constraints:

You can also have the Request passed in to the callback:

Route Sections

You can also define a section to control a group of routes.

You can also pass in a set of default parameters to be used by the request, useful for defining routes that require auth for example.