Annotation doesn't work any more after upgrading php7.4 to 8.1.
I upgrade a php7.4 project to php8.1.9, then annotations don't work:
The annotation "@ODM\Document" in class ... was never imported.
Some examples of annotations are:
use Zend\Form\Annotation;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/**
* @ODM\Document
* @Annotation\Name("client")
* @Annotation\Attributes({"novalidate": "true"})
*/
I have checked the above two classes exist under vendor/.
I have also run composer dumpautoload.
There also exist AnnotationDriver of Doctrine:
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php;
vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php
In addition, the version of their packages are not changed.
My questions:
- Firstly what's the most effective way to make the system work or identify problems ?
- I'm considering, do I have to replace all the annotations to PHP8 attributes ? But this doesn't look necessary or practical. There're huge amount of annotations. Even if I can replace those annotations of my project, the vendor packages still use annotations and definitely I can't change them.
- Just wondering, which version of Doctrine Mongodb ODM support PHP8 attributes ?
- Just guessing, is it because PHP8 makes the current Zend framework 2 and Doctrine ODM broken and thus causing annotation not work any more? If so, how to fix?
The related packages are as the following:
- "zendframework/zendframework" : "2.3.10"
- "doctrine/annotations" : "1.2.8",
- "doctrine/mongodb": "1.2.2" (There's no version for PHP8, so I have to install it as github VCS package )
- "mongodb/mongodb" : "^1.0.1",
- "doctrine/mongodb-odm" : "1.0.0-BETA14",
- "doctrine/doctrine-mongo-odm-module" : "0.8.0",
- "doctrine/annotations" : "1.2.8",
- "doctrine/common": "2.4.4",
- "doctrine/doctrine-module": "0.8.2",
If you need further resources, please let me know. Thanks!