Router with variable path and with additional GET parameters in the url

Hi, how can I do to route the following URL?


$app->get(’User/{token:/(.+)[?]}’, ‘User:login’);

This is correct?
And how do I get the values ​​of the token and the GET parameters in my controller?

public function something($request, $response){
        $username =  $request->getParam('username');

extract token with args ‘user/token/???’

1 Like
  "message": "Slim Application Error",
  "exception": [
      "type": "FastRoute\\BadRouteException",
      "code": 0,
      "message": "Regex \"/(.+)[?]\" for parameter \"token\" contains a capturing group",
      "file": "/var/www/",
      "line": 145,


$app->get(’User/{token}’, ‘User:login’);

$arrInputParams = $objRequest->getParams();
  string(13) ""
  string(5) "23456"

How to get the token value? (AAAAA)

Doing this from my phone, so forgive the brevity.

Your controller action method should take three parameters; request, response and arguments array. You’ll find the value that you’re looking for in the array :+1:

1 Like

Thanks, I was getting complicated with the regular expression and it was not necessary. It’s solved.

1 Like