Symfony 2 - An annotation in a property does not exist or cannot be loaded automatically.

I am doing a symfony 2 tutorial - Doctrine and Databases.

I created a Pages.php file in Entity / Pages.php

<?php namespace Dproc\MainBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** * @IgnoreAnnotation("fn") * */ /** * @ORM\Entity * @ORM\Table(name="pages") */ class Pages { /** * @ORM\ID * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $ID; /** * @ORM\Column(type="text") */ protected $page_title; /** * @ORM\Column(type="text") */ protected $page_content; /** * @ORM\Column(type="text") */ protected $page_category; } 

Now I am trying to generate setters and getters for this class with this command.

 php app/console doctrine:generate:entities Dproc/MainBundle/Entity/Pages 

He reports:

 [Doctrine\Common\Annotations\AnnotationException] [Semantical Error] The annotation "@Doctrine\ORM\Mapping\ID" in property Dp roc\MainBundle\Entity\Pages::$ID does not exist, or could not be auto-loade d. 

What am I doing wrong?

+6
source share
2 answers

Change your ID $ with the following code:

 /** * @var integer * * @ORM\Column(type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ private $id; 
+10
source

I think this is Case Sensitive, try:

 @ORM/Id 
+3
source

Source: https://habr.com/ru/post/956217/


All Articles