This section will describe how to define routes in PyroCMS. It helps to know how to route in Laravel already.

Laravel Routing

While most routing in Pyro will occur within your addon service provider you can still route as you normally would with Laravel using the /routes directory.

Route::get('example', function () {
    return view('theme::hello');

To learn more about native routing please refer to Laravel documentation.

Addon Service Providers

Most routing is specified within the relevant addon's service provider using the $routes and $api properties.

The most basic route definition looks like this:

protected $routes = [
    'example/uri' => 'Example\ExampleModule\Http\Controller\[email protected]',
The Route Definition

Below is a list of all routes definition properties available.

Definitions are always keyed by the URI path/pattern like this:

protected $routes = [
    'posts/{slug}' => $definition,
Key Required Type Default Description
uses true string none The `Controller\[email protected]` string handling the response.
as false string none The name of the route.
verb false string any The request verb to route. Available options are `get`, `post`, `put`, `patch`, `delete`, and `options`
middleware false array [] An array of additional middleware to run for the route.
contraints false array [] An array of parameter constraints to force on any segment parameters.
streams::addon false string The addon providing the route. The dot namespace of the addon responsible for the route. This is used in setting the active module during a request.