We do in symfony like this:
/**
* @Route("/", defaults={"id" = 1})
* @Route("/{id}")
*/
public function showAction($id)
{
}
I would like similar routing in a custom framework. How the doc can be pursed in code?
Symfony
is using Doctrine\Common\Annotations\AnnotationReader
class to parse docblocks and search for annotations. So using it outside Symfony
framework would be just using this class: read annotation and do whatever you like with custom annnotation.
Check AnnotationReader documentation and this blog entry with detailed instruction how to create your own annotation (this is Symfony
related blog post but it's not using any of Symfony
features apart from service container there )