File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,28 @@ out here.
255255
256256.. include :: /_includes/_annotation_loader_tip.rst.inc
257257
258+ Some final example to use routes as annotations::
259+
260+ \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader([$loader, 'loadClass']);
261+
262+ use Symfony\Component\Routing\Matcher\UrlMatcher;
263+ use Symfony\Component\Routing\RequestContext;
264+
265+ $loader = new \Symfony\Component\Routing\Loader\AnnotationDirectoryLoader(
266+ new \Symfony\Component\Config\FileLocator(__DIR__.'/app/controllers/'),
267+ new \Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader(
268+ new \Doctrine\Common\Annotations\AnnotationReader()
269+ )
270+ );
271+
272+ $routes = $loader->load(__DIR__.'/app/controllers/');
273+
274+ $context = new RequestContext('/');
275+
276+ $matcher = new UrlMatcher($routes, $context);
277+
278+ $parameters = $matcher->match($_SERVER['REQUEST_URI']);
279+
258280The all-in-one Router
259281~~~~~~~~~~~~~~~~~~~~~
260282
You can’t perform that action at this time.
0 commit comments