因此,我已經完成了Symfony 3的新安裝,嘗試設置一些API路由,但我無法訪問控制器內的容器。 我控制器從基本的Symfony控制器,它具有ContainerAwareTrait延伸,但是當我嘗試做$this->container->get('service')我收到此錯誤: "message": "Call to a member function get() on null",
"cla
class HelloController
{
/**
* @Route("/", name="hello")
*/
public function indexAction($name)
{
return new Response($name);
}
}
我想將變量$ name傳遞給indexAction而不使用路由。