Chrisissorry
Chrisissorry

Reputation: 1514

symfony doctrine:generate:entities cannot auto-load annotations

I run Symfony 3.1.5, PHP 7.0.12 and composer 1.2.1.

I have a simple entity:

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Event
 * @package AppBundle\Entity
 * @ORM|Entity
 * @ORM|Table(name="event")
 */
class Event
{
    /**
     * @ORM|Column(type="integer")
     * @ORM|Id
     * @ORM|GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM|Column(type="guid")
     */
    private $uuid;

    /**
     * @ORM|Column(type="string", length=100)
     */
    private $name;

    /**
     * @ORM|Column(type="text")
     */
    private $description;

    /**
     * @ORM|Column(type="datetimetz")
     */
    private $startDate;

    /**
     * @ORM|Column(type="datetimetz")
     */
    private $endDate;

    /**
     * @ORM|Column(type="text")
     */
    private $location;
}

The documentation states that I can run

php bin/console doctrine:generate:entities AppBundle/Entity/Event

in order to create getters and setters for my private attributes. I run into the following error there:

  [Doctrine\Common\Annotations\AnnotationException]
  [Semantical Error] The annotation "@Doctrine\ORM\Mapping" in class AppBundle\Entit
  y\Event does not exist, or could not be auto-loaded.

As the annotation exists as alias @ORM I guessed it is an autoloading problem.

I googled around and found some old post which linked to this plugin, which also does not work.

All posts seem to be related to the fact that the Doctrine\ORM\Mapping class is not autoloaded in the conventional way, but needs to be loaded separately. But I cannot find a definite guide on how to get this up and running for the console. Could you please help?

Upvotes: 1

Views: 393

Answers (1)

tchartron
tchartron

Reputation: 717

You should replace your annotations with the following :

/**
 * EntityName
 *
 * @ORM\Table(name="table_name")
 * @ORM\Entity(repositoryClass="PATH TO REPO")
 */

use \ instead of |

Upvotes: 1

Related Questions