Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php8.1 doctrine/orm 2.13 unknown class: Doctrine\Persistence\Mapping\Driver\AnnotationDriver #456

Closed
Dryzler opened this issue Oct 7, 2022 · 8 comments

Comments

@Dryzler
Copy link

Dryzler commented Oct 7, 2022

Hello,

i upgraded to ubuntu 22.04 LTS with php 8.1.

Then i upgraded doctrine/orm to 2.13.*

I got the error: unknown class Doctrine\Common\Cache\ArrayCache

Then i updated my doctrine cli config as mentioned here:
https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/configuration.html

I got the error: unknown class: Symfony\Component\Cache\Adapter\ArrayAdapter

Then i followed the instruction here
https://github.com/doctrine/orm/blob/2.9.x/UPGRADE.md
and installed symfony/cache

i got the error: unknown class: Doctrine\Common\Annotations\AnnotationReader

Then i installed doctrine/annotations

i got the error: unknown class: Doctrine\Persistence\Mapping\Driver\AnnotationDriver

What to do now?

My composer.json looks like this:
"require" : { "doctrine/orm" : "2.13.*", "symfony/cache": "^6.1", "doctrine/annotations": "^1.13" }

@Dryzler Dryzler changed the title php8.1 doctrine/orm 2.13 unknown class: Doctrine\Common\Cache\ArrayCache php8.1 doctrine/orm 2.13 unknown class: Doctrine\Persistence\Mapping\Driver\AnnotationDriver Oct 7, 2022
@greg0ire
Copy link
Member

greg0ire commented Oct 7, 2022

What to do now?

Provide us with a stack trace

@Dryzler
Copy link
Author

Dryzler commented Oct 7, 2022

Fatal error: Uncaught Exception: unknown class: Doctrine\Persistence\Mapping\Driver\AnnotationDriver in /code/letsraid/libsoftech/_include/_boot.php:179
Stack trace:
#0 [internal function]: Workspace\{closure}()
#1 /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/CompatibilityAnnotationDriver.php(12): class_exists()
#2 /code/letsraid/vendor/composer/ClassLoader.php(571): include('...')
#3 /code/letsraid/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#4 /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php(34): Composer\Autoload\ClassLoader->loadClass()
#5 /code/letsraid/vendor/composer/ClassLoader.php(571): include('...')
#6 /code/letsraid/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#7 /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php(75): Composer\Autoload\ClassLoader->loadClass()
#8 /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/ORMSetup.php(43): Doctrine\ORM\ORMSetup::createDefaultAnnotationDriver()
#9 /code/letsraid/libsoftech/_include/_boot.php(352): Doctrine\ORM\ORMSetup::createAnnotationMetadataConfiguration()
#10 /code/letsraid/_boot.php(6): require('...')
#11 /code/letsraid/config/cli-config.php(7): require_once('...')
#12 /code/letsraid/vendor/doctrine/orm/bin/doctrine.php(51): require('...')
#13 /code/letsraid/vendor/doctrine/orm/bin/doctrine(4): include('...')
#14 /code/letsraid/vendor/bin/doctrine(117): include('...')
#15 {main}
  thrown in /code/letsraid/libsoftech/_include/_boot.php on line 179

@greg0ire
Copy link
Member

greg0ire commented Oct 7, 2022

#0 [internal function]: Workspace\{closure}()

This part looks suspicious. If you run php /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/CompatibilityAnnotationDriver.php, do you get the same error?

@Dryzler
Copy link
Author

Dryzler commented Oct 7, 2022

when i run your command i get:

PHP Fatal error: Uncaught Error: Interface "Doctrine\Persistence\Mapping\Driver\MappingDriver" not found in /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/CompatibilityAnnotationDriver.php:14
Stack trace:
#0 {main}
thrown in /code/letsraid/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/CompatibilityAnnotationDriver.php on line 14

@Dryzler
Copy link
Author

Dryzler commented Oct 7, 2022

the closure is from my projects autoloader:

spl_autoload_register(function($class) {...});

@Dryzler
Copy link
Author

Dryzler commented Oct 7, 2022

If you install a fresh ubuntu2204 and use the composer.json i have shown, everybody would get the same error i think.

@Dryzler
Copy link
Author

Dryzler commented Oct 7, 2022

hm, i found the "problem"..

I throw an Exception if my autoloader does not find a class. If i don't throw an Exception in my autoloader, the failure mentioned does not occur.

@stof
Copy link
Member

stof commented Oct 7, 2022

throwing when you don't find a class will break class_exists.
I'm closing this issue as the problem is in your own code.

@stof stof closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants