sonata-user-bundlesymfony4

Symfony 4 Sonata User Bundle Installation


I followed all instructions from installation guide but still have this error during installation of Sonata User Bundle on Symfony 4 application:

Column name `id` referenced for relation from Application\Sonata\UserBundle\Entity\User towards Sonata\UserBundle\Entity\BaseGroup does not exist.

My config is totally same as in installation guide.

Didn't find any solutions on stackoverflow or anywhere else.


Solution

  • Finally I found the solution, but it took some time, so I want to post it here for everyone who encounter this problem.

    Adding this code to config (e.g. sonata_core.yaml):

    sonata_user:
        class:
            user:               Application\Sonata\UserBundle\Entity\User
            group:              Application\Sonata\UserBundle\Entity\Group
    

    and changing values of user_class and group_class in config (e.g. fos_user.yaml) solves problem:

    fos_user:
        db_driver:      orm
        firewall_name:  main
        user_class:     Application\Sonata\UserBundle\Entity\User
        from_email:
            address:        noreply@example.com
            sender_name:    John Doe
    
        group:
            group_class:   Application\Sonata\UserBundle\Entity\Group
            group_manager: sonata.user.orm.group_manager
    
        service:
            user_manager: sonata.user.orm.user_manager
    

    There is nothing about this in installation guide, I found it in advanced configuration chapter.

    Hope this helps someone.