use League\Uri\Components\Query; $query = Query::createFromPairs([ 'page' => 1, 'limit' => 10, ]); $url = (string)Uri\Http::createFromComponents([ 'host' => 'example.com', 'scheme' => 'https', 'path' => '/search', 'query' => (string)$query, ]); echo $url; // Output: https://example.com/search?page=1&limit=10
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; $route = new Route('/articles/{id}'); $route->setDefault('id', '1'); $routes = new RouteCollection(); $routes->add('article', $route); $context = new RequestContext(); $context->fromRequest(Request::createFromGlobals()); $generator = new UrlGenerator($routes, $context); $url = $generator->generate('article', [ 'id' => 2, '_format' => 'html', ], UrlGenerator::ABSOLUTE_URL); echo $url; // Output: http://localhost/app_dev.php/articles/2.htmlThis example shows how to generate a URL using the `UrlGenerator` component of the `symfony/routing` package. This component allows you to define routes using a `RouteCollection`, and generate URLs for those routes using the `UrlGenerator` service. In conclusion, PHP URL Render is a package library consisting of various components such as Uri and Routing from different third-party packages like `league/uri` and `symfony/routing`. These components provide a convenient way to generate URL's with proper encoding and query strings.