How to address the bundle in php app/console generate:doctrine:crud

回眸只為那壹抹淺笑 提交于 2019-12-01 22:02:59

After all it turned out that I have to create the entity before I can create the CRUD controller for it. Of course that makes sense. Unfortunately the Sensio Generator Bundle documentation does list the operations in the oposite order which pushed me into the wrong direction.

This means the correct order ist

  1. Generating a New Bundle Skeleton
  2. Generating a New Doctrine Entity Stub
  3. Generating a CRUD Controller Based on a Doctrine Entity

First you need to register your bundle into your AppKernel.

Then simply run the following command.
Don't put @ before the bundle's name

php app/console generate:doctrine:crud --entity=PeopleServiceBundle:Group

More about generating a CRUD controller based on a Doctrine entity.

According to the symfony docs, you have to use " The entity name given as a shortcut notation containing the bundle name in which the entity is located and the name of tvhe entity", so it should be something like

--entity=CinergyPeopleServiceBundle:Group

If you have more than one Bundle and want to use different database connection just update your config.yml and parameters.yml by adding configuration and parameters.

This will solve problem with CRUD generation.

I searched for hours until I found out that in my app/config/config.yml under doctrine.orm I removed auto_mapping: true which caused the issue. This may be useful for other people :)

If it still relevant for someone :) guys, it's because DoctrineBundle DoctrineExtension compile the list of valid aliases based on all registered bundles, that have 'Entity' (or other configured) folder in them.

So in order to use doctrine:generate:crud or generate:doctrine:crud, you have to create just folder Entity in your bundle, and not required to create entity first (as command says - it's true).

So you it will work if you already have some entity in your bundle, or if you have just empty Entity folder in your bundle.

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