我从fosrestbundle开始,当我获得没有关系的实体的值并在浏览器中显示它时,我没有问题。但是,当我尝试获得关系实体时,它向我显示了一个错误:500。
这是代码:
app/config/config.yml
:
fos_rest:
routing_loader:
default_format: json
param_fetcher_listener: true
body_listener: true
format_listener: true
view:
view_response_listener: 'force'
ApiRestBundle/Controller/UserController
(这可以正常工作)
/**
* @return array
* @RestGet("/users")
* @RestView()
*/
public function getUsersAction()
{
$response = array();
$em = $this->getDoctrine()->getManager();
$users = $em->getRepository('CASUsuariosBundle:User')->findAll();
$view = $this->view($users);
return $this->handleView($view);
}
APIRestBunde/Controller/CategoryController
(这不起作用)
/**
* @return array
* @RestGet("/categories")
* @RestView()
*/
public function getCategoriesAction()
{
$response = array();
$em = $this->getDoctrine()->getManager();
$categories = $em->getRepository('CASEventBundle:Category')->findAll();
$view = $this->view($categories);
return $this->handleView($view);
}
错误代码:
{"错误":{"代码":500,"消息":"内部服务器 错误","异常":[{"消息":"注意:未定义的索引: 名称"," class":" Symfony Component debug exception contexterRorexception"," trace":[{" namespace":"," short_class":" short_class":","," class":","," type"," type":"," function":"," file":" c: xampp htdocs caspruebas caspruebas vendor doctrine odtrine orm lib lib lib doctrine orm orm persisters basic entertity basic ententitypersitypersister.php","args":[]} ...
您的问题有点复杂。
此错误代码可能意味着很多不同的事情!
,但我认为这不是直接的Fosrestbundle问题。也许您在类别实体上有一个关系问题...
以下结果是什么:学说:架构:验证
编辑:如果您给我们完整的错误代码,也许可以更简单地解决它。