Generating CRUD in symfony 4

Mahdi picture Mahdi · Dec 16, 2017 · Viewed 21.8k times · Source

After releasing Symfony 4.0, there is no support for SensioGeneratorBundle. hence the command php app/console generate:doctrine:crud is not available.

They suggest to use MakerBundle, but I could not find appropriate replacement for CRUD generation.

Could anyone help?

Answer

Martijn picture Martijn · Apr 24, 2018

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!