1
class HelloController
{
/**
* @Route("/", name="hello")
*/
public function indexAction($name)
{
return new Response($name);
}
}
我想将变量$ name传递给indexAction而不使用路由。如何将变量传递给控制器而无需路由?
在文档,我发现:
services:
# ...
# explicitly configure the service
AppBundle\Controller\HelloController:
public: true
tags:
# add multiple tags to control
- name: controller.service_arguments
action: indexAction
argument: logger
# pass this specific service id
id: monolog.logger.doctrine
这表明我们如何通过其他服务来控制,但如何通过一个简单的变量?