The documentation you are viewing is for an older version of this component.
Switch to the latest (v2) version.
Following this tutorial assumes that you already completed the installation and configuration steps.
Get an instance of the Dot\Router\RouteCollector using the below code:
/** @var \Dot\Router\RouteCollectorInterface $routeCollector */
$routeCollector = $container->get(\Dot\Router\RouteCollectorInterface::class);
$routeCollector->route('/resource/manage', SomeHandler::class, 'route-name', ['GET', 'POST']);
route() method arguments:
$routeCollector->any('/resource/manage', SomeHandler::class, 'route-name');
any() method arguments:
$routeCollector->delete('/resource/{id}', SomeHandler::class, 'route-name');
delete() method arguments:
$routeCollector->get('/resource/{id}', SomeHandler::class, 'route-name');
get() method arguments:
$routeCollector->patch('/resource/{id}', SomeHandler::class, 'route-name');
patch() method arguments:
$routeCollector->post('/resource', SomeHandler::class, 'route-name');
post() method arguments:
$routeCollector->put('/resource/{id}', SomeHandler::class, 'route-name');
put() method arguments:
To facilitate creating routes, each $routeCollector method returns the existing RouteCollector instance, so you can chain routes like this:
$routeCollector
->route('/product', SomeHandler::class, 'app::product', ['GET', 'POST'])
->any('/category', SomeHandler::class, 'app::category')
->delete('/order/{id}', SomeHandler::class, 'app::delete-order')
->get('/order/{id}', SomeHandler::class, 'app::view-order')
->patch('/order/{id}', SomeHandler::class, 'app::update-order')
->post('/order', SomeHandler::class, 'app::create-order')
->put('/order/{id}', SomeHandler::class, 'app::replace-order');