“Class XXX is not a valid entity or mapped super class” after moving the class in the filesystem

前端 未结 12 1138
悲哀的现实
悲哀的现实 2020-12-01 08:51

I had an entity class in Aib\\PlatformBundle\\Entity\\User.php

I had no problems trying to create its form class through

php app/ console doc

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-01 09:33

    I solved this by passing false as the second parameter to Doctrine\ORM\Configuration::newDefaultAnnotationDriver.

    It took me a while of digging through Google and source code.

    My case was sort of special since I was using a mapping pointing to another directory unrelated to the Symfony installation as I also had to use legacy code.

    I had refactored legacy entities and they stopped working. They used to use @Annotation instead of @ORM\Annotation, so after refactoring it simply failed to read the metadata. By not using a simple annotation reader, everything seems to be okayish.

提交回复
热议问题