Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine2 [Semantical Error] Couldn't find constant?

I have an error when I am trying to run doctrine:generate:entities:

[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] Couldn't find constant ?, property Smartnode\TalkBundle\Entity\Post::$postowner.

This is my post entity class:

namespace Smartnode\TalkBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Post
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Smartnode\TalkBundle\Entity\PostRepository")
 */
class Post
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var integer
     *
     * @ORM\ManyToOne(targetEntity=“Smartnode\userBundle\Entity\User“)
     * @JoinColumn(name="postowner_id", referencedColumnName="id")
     */
    protected $postowner;

    /**
     * @var integer
     *
     * @ORM\ManyTonOne(targetEntity=“Smartnode\TalkBundle\Entity\Chan“)
     */
    private $postchan;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="creationdate", type="datetime")
     */
    private $creationdate;

And this is my User entity class:

namespace Smartnode\userBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;



/**
 * @ORM\Entity(repositoryClass="Smartnode\userBundle\Entity\UserRepository")
 * @ORM\Table(name="fos_user")
 */
class User extends BaseUser
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
like image 580
Aurélien Pigot Bennour Avatar asked Mar 12 '14 07:03

Aurélien Pigot Bennour


2 Answers

The probleme Was the quote :/

with the good quote all is working

Thanks All for help

like image 65
Aurélien Pigot Bennour Avatar answered Oct 16 '22 20:10

Aurélien Pigot Bennour


The answer of the question creator is correct. Anyways it is unclear, what he means by the problem was the quote.

Also ' should be used instead of a " to quote the values of the annotation attributes.

The issue for me was, that a quote was missing.

Wrong code:

/**
 * @ORM\OneToMany(targetEntity="UnternehmenBrancheZuordnung", mappedBy=_unternehmen")
 * @var ArrayCollection $_branchenZuordnungen
 */
private $_branchenZuordnungen;

Right code:

/**
 * @ORM\OneToMany(targetEntity="UnternehmenBrancheZuordnung", mappedBy="_unternehmen")
 * @var ArrayCollection $_branchenZuordnungen
 */
private $_branchenZuordnungen;

Here the missing quote is highlighted: mappedBy="_unternehmen"

like image 28
Jakob Alexander Eichler Avatar answered Oct 16 '22 18:10

Jakob Alexander Eichler