Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In symfony request how do I get the uri path without the query params?

$request = new Symfony\Component\HttpFoundation\Request()
$request->getRequestUri();

Seems to return the path and the query params. How to I get just the path?

like image 253
srayner Avatar asked Oct 05 '17 14:10

srayner


2 Answers

strtok($request->getRequestUri(), '?');

...or...

$request->getBaseUrl() . $request->getPathInfo();
like image 121
Russ Avatar answered Nov 05 '22 13:11

Russ


$request->getPathInfo() is what you're looking for.

like image 29
Bartosz Zasada Avatar answered Nov 05 '22 13:11

Bartosz Zasada