9

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);
4
  • 2
    Could you also post your composer.json as well as the PHP version of BOTH systems? Commented Nov 13, 2018 at 15:40
  • 2
    Try composer require doctrine/annotations it's a requirement but maybe it's broken in your code base
    – Barkermn01
    Commented Nov 14, 2018 at 22:56
  • 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 it Commented Nov 15, 2018 at 10:19
  • maybe this? github.com/goaop/framework/issues/291
    – Shobi
    Commented Nov 15, 2018 at 19:02

2 Answers 2

11

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

composer require doctrine/annotations
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.