Generating CRUD in symfony 4

You can use the make command in Symfony4+ (and it's quite an improvement!), from the MakerBundle:

php bin/console make:crud

It'll prompt you for which entity you want the crud for. It generates a controller with index, new, update, view and delete methods in /src/controller, with matching templates in /templates.

Useful to know: If you run make:entity, and later run that command again and enter an existing entity, it responds with:

Your entity already exists! So let's add some new fields!


At the moment MakerBundle supports just a few core commands. You can see the list here. Unfortunately there's no CRUD generator. But there some discussion about it in the issues so you can follow what will be done.

If what you need is just a generator for boilerplate code and not a more structured solution like EasyAdminBundle you should consider creating your own maker.

Tags:

Crud

Symfony4