为了账号安全,请及时绑定邮箱和手机立即绑定

符号 cmd 错误“目标实体..在中找不到..”

符号 cmd 错误“目标实体..在中找不到..”

PHP
慕码人2483693 2022-09-25 20:18:51
我从辛福尼框架开始,我正在努力建立许多人的关系。但是当我尝试这个命令行时php bin/console doctrine:schema:update我收到此错误:The target-entity C:\xampp\htdocs\symfony-tp\src\Entity\Competetence cannot be found in 'App\Entity\Stagiaire#competencies'.斯塔吉耶尔.php<?phpnamespace App\Entity;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass="App\Repository\StagiaireRepository") */class Stagiaire{    /**     * @ORM\ManyToMany(targetEntity="C:\xampp\htdocs\symfony-tp\src\Entity\Competetence",cascade={"persist"})     */    private $competencies;    /**     * @ORM\Id()     * @ORM\GeneratedValue()     * @ORM\Column(type="integer")     */    private $id;    /**     * @ORM\Column(type="datetime")     */    private $createdAt;    /**     * @ORM\Column(type="string", length=50)     */    private $name;    /**     * @ORM\Column(type="integer")     */    private $phone;    /**     * @ORM\Column(type="datetime")     */    private $birthday;    /**     * @var \Datetime     */    private $date;    public function __construct()    {        $this->date = new \Datetime();        $this->competencies = new ArrayCollection();    }    public function addCompetence(Competence $competence)    {        $this->$competence[] = $competence;        return $this;    }    public function removeCompetence(Competence $competence)    {        $this->competencies->removeElement($competence);    }    public function getCompetencies()    {        return $this->competencies;    }    public function getId(): ?int    {        return $this->id;    }    public function getCreatedAt(): ?\DateTimeInterface    {        return $this->createdAt;    }    public function setCreatedAt(\DateTimeInterface $createdAt): self    {        $this->createdAt = $createdAt;        return $this;    }    public function getName(): ?string    {        return $this->name;    }    public function setName(string $name): self    {        $this->name = $name;        return $this;    }
查看完整描述

1 回答

?
一只名叫tom的猫

TA贡献1906条经验 获得超3个赞

在注释中,您需要提供 的完全限定类名,而不是计算机上的文件路径,这将是Stagiaire::$competenciesCompetenceApp\Entity\Competence

所以这个:

    /**
     * @ORM\ManyToMany(targetEntity="C:\xampp\htdocs\symfony-tp\src\Entity\Competetence",cascade={"persist"})
     */
    private $competencies;

成为:

    /**
     * @ORM\ManyToMany(targetEntity="App\Entity\Competence",cascade={"persist"})
     */
    private $competencies;


查看完整回答
反对 回复 2022-09-25
  • 1 回答
  • 0 关注
  • 73 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号