获得了我捆绑包的以下结构:
Presentation->Api->Rest->Controller->CoachController->getCoaches
我正在尝试从其他捆绑包转发到它,但是我不断收到以下错误:
{"error":{"code":500,"message":"Internal Server Error","exception":[{"message":"Class \"Presentation\\Api\\Rest\\Controller:Coach\" does not exist.","class":"InvalidArgumentException",
我尝试过的是:
return $this->forward('Presentation\Api\Rest\Controller:Coach::getCoaches');
知道为什么这不起作用吗?
答案 0 :(得分:1)
您的命名空间可能有错字,这是文档的链接:https://symfony.com/doc/current/controller/forwarding.html
尝试更新您的代码:return $this->forward('Presentation\Api\Rest\Controller\CoachController::getCoaches');
顺便说一下,您的getCoaches
函数应如下所示:
namespace Presentation\Api\Rest\Controller;
...
class CoachController {
...
public function getCoaches()
{
// ... create and return a Response object
}
}