0
votes

I'm getting a well-known error for Doctrine, but nothing seems to work.

[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class ac\User\Entity\User does not exist, or could not be auto-loaded.

My class starts off like this:

<?php
namespace ac\User\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class User

My cli-config.php

<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

require_once "vendor/autoload.php";

$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src/Entity"), $isDevMode);

// database configuration parameters
$conn = array(

    'driver' => 'pdo_mysql',
);

// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);

return ConsoleRunner::createHelperSet($entityManager);

There must be 100 questions out there about this. Doctrine really needs to come to a consensus on this.

1

1 Answers

0
votes

What's your symfony version ?

If you works with symfony 4, i suggest you to install theses dependencies:

composer require symfony/orm-pack symfony/maker-bundle sensio/framework-extra-bundle

sensio/framework-extra-bundle seems to be necessary to use doctrine annotation like Entity or Table ect.