Slim 3 - Slash as part of a route parameter

I need to make urls with parameters that may contain a slash /. For example, a classic route /hello/{username}. The default /hello/Fabienwill match this route, but not /hello/Fabien/Kris. I would like to ask you how I can do this in Slim 3.

+4
source share
1 answer

Route placeholder :

For the optional "No Limit" options, you can do this:

$app->get('/hello[/{params:.*}]', function ($request, $response, $args) {
    $params = explode('/', $request->getAttribute('params'));

    // $params is an array of all the optional segments
});
+4
source

Source: https://habr.com/ru/post/1652832/


All Articles