我需要将我的应用程序与其数据库耦合。为此,我创建了一个实体doctrine:generate:entity
。它生成了一个具有适当映射注释的实体。我还使用doctrine:schema:update --force
在数据库服务器上实际创建了架构,我可以确认它已使用phpMyAdmin完成。保存Symfony实体时发生500服务器错误
在我的控制,我想简单地插入一行像这样:
public function testAction() {
$file = new File();
$file->setTest('A Foo Bar');
$em = $this->getDoctrine()->getManager();
$em->persist($file);
$em->flush();
return new JsonResponse(array('foo' => 'bar'));
}
只有一个场称为test
实体是字符串,长度为255当我要求这个网址通过AJAX在我的应用程序的请求,它会引发背部非常不提供信息500内部服务器错误:
Oops! An Error Occurred
The server returned a "500 Internal Server Error".
Something is broken. Please e-mail us at [email] and let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
的PHP错误日志也没有任何错误信息。如果我删除数据库操作的东西,此控制器操作确实有效。该应用程序也在开发环境中运行。
有什么办法可以得到一个更具描述性的错误信息,至少告诉我什么是错的?
你通常会得到Symfony完全回溯错误吗?您是否创建了触发onPersist或任何其他Doctrine事件的EventListener? –
清除缓存后再试一次! –
你是否在生产环境中运行应用程序?如果是这样,你可以尝试设置登录(点击[这里](http://symfony.com/doc/current/cookbook/logging/monolog.html#using-several-handlers)查看[文档](http:/ /symfony.com/doc/current/cookbook/logging/monolog.html#using-several-handlers)) – acrobat