symfony2 + Propel + FOSUserBundle - 找不到MyName \ MyBundle \ Entity \ User的查询类

时间:2014-04-20 20:46:32

标签: php symfony login fosuserbundle propel

重现

通过php app/console fos:user:create adminuser --super-admin添加用户;一切都好。当我转到myserver.dev/login时,会出现登录表单。我输入创建的凭据,但唯一发生的是消息 Cannot find a query class for MyName\MyBundle\Entity\User 似乎重定向到路由名称是fos_user_security_login;控制器:SecurityController;在loginAction()。成功登录后是否必须添加重定向?或者我是否必须通过操作扩展User.php实体?

这就是我做的事情

我安装了symfony 2并选择了Propel,因为它可以使迁移更容易。没有登录功能,一切正常。

  • 我添加了FOSUserBundle the setup from
  • 此外,我将login.html.twig替换为app/resources/FOSUserBundle/views/Security/login.html.twig
  • 此登录表单引用action="{{ path("fos_user_security_check") }}
    fos_user:
        db_driver: propel # other valid values are 'mongodb', 'couchdb' and 'propel'
        firewall_name: main
        user_class: MyName\MyBundle\Entity\User
    
 The security.yml is as always..
<pre>
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username
    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
            logout:       true
            anonymous:    true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

php app/console router:debug会导致:     

     home                              ANY      ANY    ANY  /
     about                             ANY      ANY    ANY  /about
     fos_user_security_login           ANY      ANY    ANY  /login
     fos_user_security_check           POST     ANY    ANY  /login_check
     fos_user_security_logout          ANY      ANY    ANY  /logout
     fos_user_profile_show             GET      ANY    ANY  /profile/
     fos_user_profile_edit             ANY      ANY    ANY  /profile/edit
     fos_user_registration_register    ANY      ANY    ANY  /register/
     fos_user_registration_check_email GET      ANY    ANY  /register/check-email
     fos_user_registration_confirm     GET      ANY    ANY  /register/confirm/{token}
     fos_user_registration_confirmed   GET      ANY    ANY  /register/confirmed
     fos_user_resetting_request        GET      ANY    ANY  /resetting/request
     fos_user_resetting_send_email     POST     ANY    ANY  /resetting/send-email
     fos_user_resetting_check_email    GET      ANY    ANY  /resetting/check-email
     fos_user_resetting_reset          GET|POST ANY    ANY  /resetting/reset/{token}
     fos_user_change_password          GET|POST ANY    ANY  /profile/change-password
    

0 个答案:

没有答案