use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $uri = $request->getUri(); echo $uri; // outputs something like "https://example.com:8080/my/path?param1=value1#section1"
$path = $request->getPathInfo(); echo $path; // outputs something like "/my/path"Package/library: The Symfony\Component\HttpFoundation namespace is part of the Symfony HttpFoundation component, which is part of the larger Symfony framework.