symfony - Symfony4 API 平台
问题描述
我将 Api 平台与 Symfony 4.2 捆绑在一起,但是当使用 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;
}
}
我需要你的帮助 :)
谢谢各位。
解决方案
我认为表名有问题,因为“组”是 MySQL 中的保留字,尝试将表名更改为其他名称。
推荐阅读
- javascript - 与 js“.sass 文件”共享 sass 变量
- java - 杰克逊在使用 JsonTypeInfo.As.WRAPPER_OBJECT 时排除特定类的包装
- javascript - 如何为具有必须匹配特定键和来自另一个数组的相同值的值的数组执行 foreach
- php - 将数组数据的字节转换为pdf下载?
- django - 如何根据 django 模型中字段的比较值进行过滤?
- scala - 在scala中处理无效参数的最佳方法是什么
- angular - 如何使用 ng-select 更改事件到达元素
- c - 是否可以以编程方式设置当前的 Linux 运行级别?
- php - 如何使用rest api在amazon中使用asin no获取产品详细信息?
- ruby - 使用 htop 命令可视化 ruby 线程