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

前端 未结 6 1423
我在风中等你
我在风中等你 2021-01-21 01:40

In my symfony 2 project I have a bundle at

src/Cinergy/Bundle/PeopleServiceBundle

Now I\'d like to generate a CRUD controller based on a doctri

相关标签:
6条回答
  • 2021-01-21 01:54

    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.

    0 讨论(0)
  • 2021-01-21 01:59

    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.

    0 讨论(0)
  • 2021-01-21 02:06

    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
    
    0 讨论(0)
  • 2021-01-21 02:08

    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 :)

    0 讨论(0)
  • 2021-01-21 02:08

    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.

    0 讨论(0)
  • 2021-01-21 02:12

    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
    0 讨论(0)
提交回复
热议问题