You can use the getPathInfo()
method of the Request
object to obtain the current request's route path in Symfony. Here's an example:
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$routePath = $request->getPathInfo(); // returns "/blog/{slug}"
You can use this code in your controller action to obtain the route path of the current request.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-10 21:26:48 +0000
Seen: 17 times
Last updated: Jul 10 '23