Parse module routes *
public static parse_routes ( $module, $uri ) |
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; $routes = new RouteCollection(); // Defines a route for the homepage $routes->add('homepage', new Route('/')); // Defines a route for a blog post with an ID parameter $routes->add('blog_post', new Route('/blog/{id}'));
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Matcher\UrlMatcher; $request = Request::createFromGlobals(); $routes = new RouteCollection(); // Add routes to collection $matcher = new UrlMatcher($routes, $context); $parameters = $matcher->matchRequest($request); // If the request URL matches a defined route, the match() method will return the array of parameters // associated with that routeIn both examples, the Symfony Routing Component is being used. The parse_routes module is a part of this component and allows developers to define and match routes in their application.