doctrine2 autloader with cli must use AnnotationRegistry

前端 未结 2 2041
-上瘾入骨i
-上瘾入骨i 2021-02-06 11:20

I must use \\Doctrine\\Common\\Annotations\\AnnotationRegistry::registerFile to access the annotation registry in entity files.

This part is required to use

2条回答
  •  有刺的猬
    2021-02-06 11:58

    It seems your AnnotationRegistry isn't set up.

    Add the following to your script:

    use Doctrine\Common\Annotations\AnnotationRegistry;  
    
    AnnotationRegistry::registerFile("/path/to/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
    

    see Doctrine manual on Annotations for the detailed explanation.
    In short: to read the annotations PSR-0 and spl autoloading can't do the job, you have to use their solution.

提交回复
热议问题