Skip to content

Handler Groups

Jakob Tapuć edited this page May 4, 2021 · 4 revisions

Introduction

Sometimes you want to group some handlers under a specific prefix. The group() method does exactly that:

$app->routes(function (Routes $routes) {
    $routes->group('/hello', function (Routes $routes) {
        $routes->get('/', /* */);

        $routes->group('/nested', function (Routes $routes) {
            $routes->post('/', /* */);
        });
    });
});

Groups can be arbitrarily nested.

Clone this wiki locally