Interactive generators make creating new bundles, CRUD controllers, entities and forms very easy indeed. You can list all of the out of the box functions at the terminal by calling,
php app/console |
The interactive generators are listed under the sub-heading of generator.
generate generate:bundle Generates a bundle generate:doctrine:crud Generates a CRUD based on a Doctrine entity generate:doctrine:entities Generate entity classes and method stubs from your mapping information generate:doctrine:entity Generates a new Doctrine entity inside a bundle generate:doctrine:form Generates a form type class based on a Doctrine entity |
In the remainder of this post I am going to talk a little about the CRUD generator could be described as your answer to the missing admin controller. It makes creating, reading, updating and deleting (hence the name) your database objects very easy.
First of all you must create an object that is to be persisted,
generate php app/console generate:doctrine:entity |
This generator will take you through a series of steps to create the entity, specifying each property and its type. To create the CRUD for this is simple,
generate php app/console generate:doctrine:crud |
This will take you through another series of steps where you have to specify if the generator should create write actions, the configuration format (my personal preference is always for annotations) and finally the route prefix. Once you have done this you now have an entity that is essentially a php object and a controller and a series of forms that allow you to create, write, updated and delete those objects. It is verbs simple but saves huge amounts of time so give interactive generators a go.
On the Symfony 2.0 website there is a great tutorial video that illustrates how to use these new interactive generators.