Symfony sonata user bundle configuration issue

531 Views Asked by At

enter code hereI followed instructions from this url:

https://docs.sonata-project.org/projects/SonataUserBundle/en/4.x/reference/installation/#configuration

I was able to see the admin page but when I tried to add a user, and I got the following error:

No entity manager defined for class "App\Entity\SonataUserUser".

My doctrine.yaml has the following information:

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    SonataUserBundle: ~
                    FOSUserBundle: ~
    dbal:
        url: '%env(resolve:DATABASE_URL)%'`enter code here`

My framework.yaml has the following information:

framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
#http_method_override: true

support.
    session:
        handler_id: null
        cookie_secure: auto
        cookie_samesite: lax

    #esi: true
    #fragments: true
    php_errors:
        log: true
    templating:
        engines:
            twig

My sonata_user.yaml has the following information:

sonata_user:
class:
    user: App\Entity\SonataUserUser
    group: App\Entity\SonataUserGroup
#security_acl: true
manager_type: orm # can be orm or mongodb

My security.yaml has the following information:

security:

access_control:
    # Admin login page needs to be accessed without credential
    - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

    # Secured part of the site
    # This config requires being logged for the whole site and having the admin role for the admin part.
    # Change these rules to adapt them to your needs
    - { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
    - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

role_hierarchy:
    ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
    ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
    SONATA:
        - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt

providers:
    fos_userbundle:
        id: fos_user.user_provider.username
    

firewalls:
    # Disabling the security for the web debug toolbar, the profiler and Assetic.
    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

    # -> custom firewall for the admin area of the URL
    #admin:
    #    pattern:            /admin(.*)
    #    context:            user
    #    form_login:
    #        provider:       fos_userbundle
    #        login_path:     /admin/login
    #        use_forward:    false
    #        check_path:     /admin/login_check
    #        failure_path:   null
    #    logout:
    #        path:           /admin/logout
    #        target:         /admin/login
    #    anonymous:          true

    # -> end custom configuration

    # default login area for standard users

    # This firewall is used to handle the public login area
    # This part is handled by the FOS User Bundle
    #main:
    #    pattern:             .*
    #    context:             user
    #    form_login:
    #        provider:       fos_userbundle
    #        login_path:     /login
    #        use_forward:    false
    #        check_path:     /login_check
    #        failure_path:   null
    #    logout:             true
    #    anonymous:          true
0

There are 0 best solutions below