Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found

Tags:

My first ever time using Doctrine and I've got an error. I left my project the night before and this error didn't exist, booted up the web server on a new machine and greeted with this.

Fatal error: Uncaught Error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found in D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php:156 Stack trace: #0 D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Setup.php(72): Doctrine\ORM\Configuration->newDefaultAnnotationDriver(Array, true) #1 D:\website\src\setup.php(16): Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(Array, true) #2 D:\website\src\bootstrap.php(6): include('C:\Users\admin\...') #3 D:\website\public\index.php(7): require('C:\Users\admin\...') #4 {main} thrown in D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php on line 156

I've tried composer update and composer install, neither have helped.

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

$paths = array(ROOT . "/src/Database/Modals");
$config = $container->get('App\Providers\Config');

$dbParams = array(
    'driver'   => $config->get('database.driver'),
    'user'     => $config->get('database.user'),
    'password' => $config->get('database.password'),
    'dbname'   => $config->get('database.name'),
);

$entityConfig = Setup::createAnnotationMetadataConfiguration($paths, true);
$entityManager = EntityManager::create($dbParams, $entityConfig);

It seems to throw the exception for this line of code.

$entityConfig = Setup::createAnnotationMetadataConfiguration($paths, true);
like image 714
Adam G Avatar asked Nov 06 '18 01:11

Adam G


1 Answers

The comment above by @martin-barker did the trick for me:

composer require doctrine/annotations
like image 137
Kerry Randolph Avatar answered Nov 14 '22 22:11

Kerry Randolph