我使用Symfony 4.2捆绑了Api平台,但是当使用Model Group.php发布数据时,出现以下错误:
"hydra:description":“无法为类型为”App\Entity\Group“的项目生成IRI”,
我不明白这个。
我的示范小组:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
/**
* @ApiResource(iri="http://schema.org/Group")
*
* @ORM\Table(name="group")
*/
class Group
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
}
我需要你的帮助:)
伙计们。
发布于 2019-04-18 22:25:27
此错误不是由实体造成的。发生这种情况是因为在config.yaml文件中做错了一些配置。
发布于 2019-04-19 04:36:14
我认为表名有问题,因为"group“是MySQL中的保留字,尝试将表名更改为其他名称。
https://stackoverflow.com/questions/53835425
复制相似问题