is there a facility for generating scaffolding in a Symfony2 app?

前端 未结 2 1028
梦谈多话
梦谈多话 2020-12-16 23:48

I\'ve been doing searches on scaffolding in Symfony 2 and keep finding references to \"generators\" but so far have not been able to get scaffolding up and working.

2条回答
  •  抹茶落季
    2020-12-17 00:33

    Crud operations are provided by the SensioGeneratorBundle which is included in the symfony standard distribution.

    You can use the following command to generate form, templates & controller for existing entitites. It is interactive and can also update your routing automatically.

    app/console generate:doctrine:crud
    

    entity classes themselfes can be created with another command - interactive aswell.

     app/console generate:doctrine:entity
    

    Generating entities from database is done with:

    app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force
    

    which will create xml mapping files. Afterwards you can generate entities as follows:

    app/console doctrine:mapping:import AcmeBlogBundle annotation
    app/console doctrine:generate:entities AcmeBlogBundle
    

    This would generate the entities with annotations. yml and xml are supported aswell!

提交回复
热议问题