Select Page

Symfony2 CRUD

Richard Elliot of Bournemouth,

Most of the SF2 sites we have (Corp/Subs/etc) were initially built around the SF2 CRUD generator. Having a play with the CRUD generator will give you a good idea of the core way in which Symfony2 works.

http://symfony.com/doc/2.0/bundles/SensioGeneratorBundle/commands/generate_doctrine_crud.html

php app/console generate:doctrine:crud

CRUD is create , read , update, delete if you didn;t know. Ie. a blog style app.

The generator automatically sets up your entity getter and setters, and the relevant controller methods.

Using Doctrine, it will then also setup your DB schema and all the relationships between your entities .

Forms:

The other important element of the CRUD is the FormTypes , which allow us to create/update/delete an entity. There is also a generator for the form types:

http://symfony.com/doc/2.0/bundles/SensioGeneratorBundle/commands/generate_doctrine_form.html

php app/console generate:doctrine:form AcmeBlogBundle:Post