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);
composer require doctrine/annotations
it's a requirement but maybe it's broken in your code base – Barkermn01..
presence in the configs can break it – Diogo Santo