Diary of problems and solutions related to web programming, database development and related technologies and platforms.

Generating CRUD based on Doctrine Entity using Symfony2

In MySql database 

Initially make sure you have your database created on the mysql.

Create a table product on that database and create the fields for the product table.

In Git Bash

We assume that you are in your project root directory

Run the following command to create crud controller

php app/console generate:doctrine:crud

This will help you list the records, add records, edit records and delete records.

Entity shortcut name: AcmeDemoBundle:Product
If you want to create write action (means if you want to create/edit/delete record), then you have enter yes
Configuration format: yml
Routes prefix [/product] : Press Enter to give the routing prefix as it is.
Do you confirm generation: Press Enter to confirm.
Confirm automatic update of routing? Press Enter to confirm.

This will create CRUD controller.

Once a controller is created, if you want to overwrite any of the things to the existing controller, then run the following command.

php app/console generate:doctrine:crud --overwrite

No comments :

Post a Comment