silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

How to group routes #1262

Closed lautiamkok closed 8 years ago

lautiamkok commented 9 years ago

Can I group my routes in Silex just as Slim framework?

For instance, in Slim,


// API group
$app->group('/api', function () use ($app) {

    // Admin group
    $app->group('/admin', function () use ($app) {

        // Get book with ID
        $app->get('/books/:id', function ($id) use ($app) {
            // Update book identified by $id.
        });

        // Update book with ID
        $app->put('/books/:id', function ($id) use ($app) {
            // Update book identified by $id.
        });

        // Delete book with ID
        $app->delete('/books/:id', function ($id) use ($app) {
            // Update book identified by $id.
        });

    });

});

Is it possible with Silex?

hkdobrev commented 9 years ago

@lauthiamkok You'd want to read the documentation on organizing controllers and mounting: http://silex.sensiolabs.org/doc/organizing_controllers.html