Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

By "scaffolding" I'm referring to a way to point your tool at a database and have it generate views/forms to perform CRUD operations.

This can be useful for quickly prototyping something, and/or build a rough admin tool for some of your database tables.

It can also provide a starting point for some form you are building.

Is this possible in Symfony2?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
390 views
Welcome To Ask or Share your Answers For Others

1 Answer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...