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

Closed
opened 2026-01-22 15:26:47 +01:00 by admin · 3 comments
Owner

Originally created by @h4r86e32 on GitHub (Nov 13, 2018).

Been battling with this problem for a while. Tried most things such as replacing vendor, running on PHP 7.2 and not sure what the problem is.

Error:

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

Initialization code:

<?php

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

$paths = array();
$config = $container->get('App\Providers\Config');

$container->get('Twig_Environment')->addFunction(new \Twig_Function('config', function ($key) use($config) {
    return $config->get($key);
}));

$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, false);
$entityManager = EntityManager::create($dbParams, $entityConfig);

Originally created by @h4r86e32 on GitHub (Nov 13, 2018). Been battling with this problem for a while. Tried most things such as replacing vendor, running on PHP 7.2 and not sure what the problem is. Error: ``` Fatal error: Uncaught Error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found in C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php:156 Stack trace: #0 C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Setup.php(72): Doctrine\ORM\Configuration->newDefaultAnnotationDriver(Array, true) #1 C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\src\setup.php(20): Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(Array, false) #2 C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\src\bootstrap.php(6): include('C:\\Users\\admin\\...') #3 C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\public\index.php(7): require('C:\\Users\\admin\\...') #4 {main} thrown in C:\Users\admin\Dropbox\workspace\coding\projects\websites\eshare\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php on line 156 ``` Initialization code: ``` <?php use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\EntityManager; $paths = array(); $config = $container->get('App\Providers\Config'); $container->get('Twig_Environment')->addFunction(new \Twig_Function('config', function ($key) use($config) { return $config->get($key); })); $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, false); $entityManager = EntityManager::create($dbParams, $entityConfig); ```
admin added the BugInvalid labels 2026-01-22 15:26:47 +01:00
admin closed this issue 2026-01-22 15:26:47 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 13, 2018):

What are the locked versions of your dependencies?

@Ocramius commented on GitHub (Nov 13, 2018): What are the locked versions of your dependencies?
Author
Owner

@h4r86e32 commented on GitHub (Nov 15, 2018):

Here is a gist of my whole composer.lock file.
https://gist.github.com/h4r86e32/f685c8da265b0a35af93a9a63a2e5e4f

@h4r86e32 commented on GitHub (Nov 15, 2018): Here is a gist of my whole composer.lock file. https://gist.github.com/h4r86e32/f685c8da265b0a35af93a9a63a2e5e4f
Author
Owner

@caugner commented on GitHub (Feb 20, 2022):

I just faced this error today after bumping some doctrine/* dependencies, including doctrine/persistence from 2.2.3 to 2.3.0, which marks doctrine/annotations as an optional dependency.

In my case the solution was to composer require doctrine/annotations myself.

@caugner commented on GitHub (Feb 20, 2022): I just faced this error today after bumping some `doctrine/*` dependencies, including `doctrine/persistence` from 2.2.3 to [2.3.0](https://github.com/doctrine/persistence/releases/tag/2.3.0), which marks `doctrine/annotations` as an optional dependency. In my case the solution was to `composer require doctrine/annotations` myself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6103