2
votes

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);
2
Could you also post your composer.json as well as the PHP version of BOTH systems?Sven Hakvoort
Try composer require doctrine/annotations it's a requirement but maybe it's broken in your code baseBarkermn01
Could you check and add if necessary the vendor directory to the excludePaths option? There have been reports where the .. presence in the configs can break itDiogo Santo

2 Answers

1
votes

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

composer require doctrine/annotations
-1
votes

1) connect you server using ssh.

2) Locate the path that your script work.

3) Run composer require doctrine/annotations

4) You can find vendor dir in FTP

5) Declare a require to vendor on your code. like require_once 'vendor/autoload.php'

Let me know if helps.