Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony2 FOSRestBundle:对于HTTP\u NO\u内容之类的代码,应该包含哪个类_Symfony_Fosrestbundle - Fatal编程技术网

Symfony2 FOSRestBundle:对于HTTP\u NO\u内容之类的代码,应该包含哪个类

Symfony2 FOSRestBundle:对于HTTP\u NO\u内容之类的代码,应该包含哪个类,symfony,fosrestbundle,Symfony,Fosrestbundle,我想抛出一个HTTP\u NO\u内容,但symfony告诉我ClassNotFoundException:试图从名称空间“FOS\Rest\Util”加载类“code”。您需要从另一个命名空间“使用”它吗? 我确实使用了FOS\RestBundle\Util\code在我的课堂上 我的电话是这样的 public function deleteAction($id) { $em = $this->getDoctrine()->getManager(); $player = $

我想抛出一个HTTP\u NO\u内容,但symfony告诉我
ClassNotFoundException:试图从名称空间“FOS\Rest\Util”加载类“code”。您需要从另一个命名空间“使用”它吗?

我确实使用了FOS\RestBundle\Util\code在我的课堂上

我的电话是这样的

public function deleteAction($id)
{
  $em = $this->getDoctrine()->getManager();
  $player = $em->getRepository('xxx')->find($id);

  $em->remove($player);
  $em->flush();

  return $this->view(null, new HTTP_NO_CONTENT);
}

为什么找不到那个类?

新的HTTP\u NO\u内容在这里没有意义!您必须使用
FOS\RestBundle\Util\Codes
class

use FOS\RestBundle\Util\Codes;
并指向正确的状态代码,如下所示

Codes::HTTP_NO_CONTENT // As HTTP_NO_CONTENT is defined as a constant