如何像 symfony 框架一样使用@route
How to use @route like symfony framework does
我们在 symfony 中是这样的:
/**
* @Route("/", defaults={"id" = 1})
* @Route("/{id}")
*/
public function showAction($id)
{
}
我想要自定义框架中的类似路由。如何在代码中获取文档?
Symfony
正在使用 Doctrine\Common\Annotations\AnnotationReader
class 解析文档块并搜索注释。因此,在 Symfony
框架之外使用它只是使用此 class:读取注释并使用自定义注释做任何你喜欢的事情。
查看 AnnotationReader documentation and this 博客条目,详细说明如何创建您自己的注释(这是 Symfony
相关的博客 post 但它没有使用任何 Symfony
功能从那里的服务容器)
我们在 symfony 中是这样的:
/**
* @Route("/", defaults={"id" = 1})
* @Route("/{id}")
*/
public function showAction($id)
{
}
我想要自定义框架中的类似路由。如何在代码中获取文档?
Symfony
正在使用 Doctrine\Common\Annotations\AnnotationReader
class 解析文档块并搜索注释。因此,在 Symfony
框架之外使用它只是使用此 class:读取注释并使用自定义注释做任何你喜欢的事情。
查看 AnnotationReader documentation and this 博客条目,详细说明如何创建您自己的注释(这是 Symfony
相关的博客 post 但它没有使用任何 Symfony
功能从那里的服务容器)