16

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?

Mahdi
  • 435
  • 3
  • 13
  • 32

4 Answers4

27

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!

Martijn
  • 14,522
  • 4
  • 29
  • 61
3

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.

dlondero
  • 2,239
  • 1
  • 22
  • 32
  • 1
    Thanks @dlondero Another question is that where's Symfony 4 debug toolbar? – Mahdi Dec 24 '17 at 05:22
  • 2
    I found it, according to documents Profiler component must be installed. – Mahdi Dec 24 '17 at 07:03
  • 1
    I was looking for this functionality and stumbled upon this answer. Since the latest release on March 14th, 2018 the `make:crud` command was added: https://github.com/symfony/maker-bundle/releases/tag/v1.2.0 – Jelle Mar 16 '18 at 18:17
0

Symfony4 (thanks to @jelle)

composer require symfony/maker-bundle --dev

composer require symfony/form symfony/validator symfony/twig-bundle symfony/orm-pack symfony/security-csrf

php bin\console make:crud

The class name of the entity to create CRUD (e.g. BravePuppy):
 >
Martijn
  • 14,522
  • 4
  • 29
  • 61
Ricardo Saracino
  • 979
  • 2
  • 12
  • 28
0

first install pre-req packages

composer require twig-bundle security-csrf

and then you can run

php bin/console make:crud

after that just enter your entity name which you want to curd

The class name of the entity to create CRUD (e.g. BlogPosts):
 >
Hassan Saeed
  • 3,178
  • 20
  • 22