How to generate code for basic operations create update read and delete in symfony


Posted on 20 Sep 16 by Vickey

Like in others php frameworks we can generate basic code automatcally. For example if you have a database table and you want to write the code for  basic operation  ‘create ’, ‘Update’,’Read’ and ‘Delete’ you don not need to write code. We can create code automatically by using commands line. but for this first we need to create an entity and repository we can create this by using command lines.

Generate Entity

php bin/console doctrine:generate:entity

after generate entity we will create tables from entity

Create table into database using entity 

php bin/console doctrine:schema:update –force

this command create tables related to all entities

Now by using the below command we create code for basic operations

Generate Create, update read delete code (CRUD Operation)

php app/console generate:doctrine:crud

when process done you can see auto generated code in your project folder



If this post help you reduce time to develop, you can help me to maintain this website :)