Multilanguage route middleware for slim 4

Hey guys!
Im starting with slim 4, and I cant find a working solution for this, I’ve read a couple of tutorials on slim 3 and even slim 2, but no luck.

This is the only thing left for me to use this amazing framework in production! Any help is appreciated.

I would like something like symfony, where we can setup maybe route groups /en/home and /de/home

Hi Oscar :slight_smile:

You can find this information in the Slim documentation: Route groups

use Slim\Routing\RouteCollectorProxy;
// ...

$app->group('/{language}', function (RouteCollectorProxy $group) {
     $group->get('/home', function ($request, $response, array $args) {
        $response->getBody()->write("Home " . $args['language']);

        return $response;
1 Like

Thank you! Works like a charm.

1 Like