use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; $request = Request::createFromGlobals(); $route = new Route($request->getUri(), ['_controller' => 'MyController']);
use Symfony\Component\HttpFoundation\Request; $request = Request::createFromGlobals(); $baseUrl = $request->getSchemeAndHttpHost(); $path = $request->getPathInfo(); $url = $baseUrl . $path;This example shows how you can use getUri to build a URL. The method getSchemeAndHttpHost returns the protocol and hostname of the request. getPathInfo returns the path of the request. By combining these two values, we can construct a fully qualified URL. Package/Library: Symfony HttpFoundation