mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
doctrine/annotations required for Doctrine Console Tools
#6921
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @llaville on GitHub (Jan 31, 2022).
Bug Report
Summary
doctrine/annotationsis required when trying to create the schema with Doctrine Console ToolsThis issue is a try to clarify what @remicollet tried to explain in report #9416 (/cc @derrabus)
Found myself the same problem in my project
bartlett/php-compatinfoCurrent behavior
Fatal error: Uncaught Error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not foundwas raised when running the Doctrine Console Toolsvendor/bin/doctrineHow to reproduce
Begin with a very simple
composer.jsoncontents :On a PHP 7.4.27 platform
Today, when I install the dependencies (
composer update), I got (composer show):We may notice that
doctrine/annotationspackage is not installed, but it's used bydoctrine/orm:See https://github.com/doctrine/orm/blob/2.11.x/lib/Doctrine/ORM/Configuration.php#L10
Following documentation : https://www.doctrine-project.org/projects/doctrine-orm/en/2.11/reference/tools.html
I create a
config/cli-config.phpfile with following contentsAnd I also create a
bootstrap.phpfile with following contentsThe Use Case Project structure look like :
At first run attempt, we got following error :
So I added
"symfony/cache": "^5.4"constraint in mycomposer.jsonfile. Update it and run once again to get final errorBecause I used the simple annotation reader (default behaviour).
See https://github.com/doctrine/orm/blob/2.11.x/lib/Doctrine/ORM/Tools/Setup.php#L75
Expected behavior
Be able to run Doctrine Console Tools (create shema) with Entities that used default
Doctrine\Common\Annotations\SimpleAnnotationReader@derrabus commented on GitHub (Jan 31, 2022):
The problem is the following line in your bootstrap.php:
This is where you actively opt-in to using annotations and this action requires
doctrine/annotationsto be installed. If for example you calledcreateAttributeMetadataConfiguration()orcreateXmlMetadataConfiguration()instead, the error would disappear.However, I think we should raise a meaningful error in
createAnnotationMetadataConfiguration()ifdoctrine/annotationsis not installed.@llaville commented on GitHub (Jan 31, 2022):
👍 confirmed to fix it ! Thanks to point me the right way !
@llaville commented on GitHub (Jan 31, 2022):
@derrabus I've made changes on my project
bartlett/php-compatinfo-db,and get another error
@llaville commented on GitHub (Jan 31, 2022):
Run new attempt with
doctrine/annotationsavailable oncomposer.jsonbut got same error.FYI:
AttributeDriver->isTransient()is called on class https://github.com/llaville/php-compatinfo-db/blob/master/src/Infrastructure/Persistence/Doctrine/Entity/ClassRelationship.phpI don't see what is wrong with this Entity.
@derrabus commented on GitHub (Jan 31, 2022):
This is because attributes are not available on PHP 7. Same issue: We should emit a meaningful error message in that case.
@llaville commented on GitHub (Jan 31, 2022):
I've perharps misunderstood what you said, but PHP attributes is a PHP 8 feature, and I don't used it !
@derrabus commented on GitHub (Jan 31, 2022):
My attempt to improve the situation: #9452