0

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

Beach Chicken
  • 368
  • 3
  • 13

0 Answers0