Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating CRUD in symfony 4

Tags:

crud

symfony4

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?

like image 914
Mahdi Avatar asked Dec 16 '17 12:12

Mahdi


2 Answers

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!

like image 106
Martijn Avatar answered Sep 21 '22 06:09

Martijn


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.

like image 27
dlondero Avatar answered Sep 21 '22 06:09

dlondero