4

您好,我使用 api 平台创建了小“foo”api,现在我正在尝试使用自己的实体,但我不断收到 404 错误,找不到资源。

我正在关注本教程: https ://api-platform.com/docs/distribution/

这是我的实体

<?php

namespace AppBundle\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
 * Job
 *
 * @ApiResource
 * @ORM\Entity
 */
class Job
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=100, nullable=false)
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="description", type="text")
     */
    private $description;

    /**
     * @var Location The location this job is about.
     *
     * @ORM\ManyToOne(targetEntity="Location", inversedBy="jobs")
     */
    private $location;

如果有人可以帮助我解决为什么这不起作用,我将不胜感激:)

提前谢谢了!

4

2 回答 2

4

大多数情况下,在修改实体或创建实体后,您必须运行:

$ php bin/console cache:clear

以使新的更改生效。我还没有找到禁用开发模式缓存的方法。

于 2017-04-19T08:19:19.717 回答
0

php -S localhost:8000 -t public 当我运行我的服务器然后我使用它时,我遇到了同样的问题symfony server:start,并且它按预期工作

于 2019-12-05T21:53:27.503 回答