Cannot load entity: “class” was not found in the chain configured

我只是一个虾纸丫 提交于 2019-12-11 16:15:38

问题


I'm new to Doctrine ORM and I have some problems retrieving an entity.

I get the following error when i try to retrieve my entity:

'AppBundle\Entity\FeedImport' was not found in the chain configured namespaces

I've used the Symfony CLI utilities mapping:import to generate my entity yaml files and generate:entities for creating the models.

I've searched for this error and most of the time it is all about custom bundles not being mapped correctly. But because I used the default bundle I don't know what should be wrong. Do I need to configure doctrine with more information?

Things I've checked:

- AppBundle is active. - AppBundle is registered. - DefaultController of the AppBundle is loaded correctly. - class FeedImport exists. - class FeedImport has correct namespace. - Tried switching naming strategy for doctrine. (It uses underscore namesping strategy by default, but my classes are in CamelCase)

Can you see what is wrong? Any advise would be appreciated. Below is my configuration/setup details.

DefaultController.php public function indexAction(Request $request) { ........... $feedImport = $this->getDoctrine()->getRepository(FeedImport::class)->find(1); ........... }

namespace of the FeedImport.php class: namespace AppBundle\Entity

config.yml

doctrine: dbal: driver: pdo_mysql host: '%database_host%' port: '%database_port%' dbname: '%database_name%' user: '%database_user%' password: '%database_password%' charset: UTF8 # if using pdo_sqlite as your database driver: # 1. add the path in parameters.yml # e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite' # 2. Uncomment database_path in parameters.yml.dist # 3. Uncomment next line: #path: '%database_path%' mapping_types: enum: string set: string orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true

App Module structure:

AppBundle ├── AppBundle.php ├── Controller │   └── DefaultController.php ├── Entity │   ├── FeedImport.php ├── Repository │   └── FeedImportRepository.php └── Resources └── config └── doctrine ├── FeedImport.orm.yml

来源:https://stackoverflow.com/questions/46308791/cannot-load-entity-class-was-not-found-in-the-chain-configured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!