'Generate admin Sonata with command line in Symfony 4

I'm starting to use Sonata with Symfony 4. I try to generate an admin with the command line "make:sonata:admin" and i've an error at the end of the process like this:

2018-10-11T15:55:23+00:00 [error] Error thrown while running command "make:sonata:admin". Message: "There are no model managers registered."
In AdminMaker.php line 286:
  There are no model managers registered.

So I try wit hthe other command line "sonata:admin:generate" and I have an other error like this :

Welcome to the AdminBundle object ACL generator
This command helps you to generate ACL entities for the objects handled by the AdminBundle.
If the step option is used, you will be asked if you want to generate the object ACL entities for each Admin.
You must use the shortcut notation like AcmeDemoBundle:User if you want to set an object owner.
Admin class is using a manager type that has no manipulator implemented : ignoring
Admin class is using a manager type that has no manipulator implemented : ignoring
Admin class is using a manager type that has no manipulator implemented : ignoring

My implementation code is like this :

  • src
    • Entity
      • Clients
      • Vehicules

Can you help me please ?

Thanks a lot for your answer



Solution 1:[1]

Try to config the service, so you can give the model manager that you use.

services:
  sonata.admin.maker:
    class: Sonata\AdminBundle\Maker\AdminMaker
    arguments: ['%kernel.project_dir%', ['@sonata.admin.manager.orm']]
    tags:
    - { name: maker.command }

Solution 2:[2]

You need to install Doctrine ORM Admin Bundle first

composer require sonata-project/doctrine-orm-admin-bundle

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Georgi Gabrovski
Solution 2 Josef Fefoid Hlavatý