Symfony2 FOSUserBundle - 您请求了一个不存在的服务“security.user_checker”

发布于 2024-12-27 11:01:53 字数 1723 浏览 1 评论 0原文

我使用 Symfony 2 和 FOSUserBundle。我可以登录、注销和查看个人资料。

问题:当我转到“/register”时,填写表单并按 Enter 键,我收到以下错误:

您请求了不存在的服务“security.user_checker”。 500 内部服务器错误 - ServiceNotFoundException

似乎我已经做了一些额外的配置,但我找不到任何相关信息。

config.yml 的一部分:

fos_user:
    db_driver: orm
    firewall_name: fos_user
    user_class: Blogger\BlogBundle\Entity\User

security.yml:

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        in_memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
        fos_user:
            id: fos_user.user_manager

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        fos_user:
            pattern:    ^/
            provider:   fos_user
            form_login:
                check_path: /login_check
                login_path: /login
            logout:
                path:   /logout
                target: /
            anonymous: ~

    access_control:
        - { path: /secured/admin, roles: ROLE_ADMIN }
        - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }

更新

堆栈跟踪:

https://i.sstatic .net/vsGwF.png

I use Symfony 2 and the FOSUserBundle. I can login, logout and view Profile.

Problem: When i go to "/register", fill out the form and press enter i get the following error:

You have requested a non-existent service "security.user_checker".
500 Internal Server Error - ServiceNotFoundException

It seems that I have do to some additional configuration or so, but I can't find anything about it.

Part of config.yml:

fos_user:
    db_driver: orm
    firewall_name: fos_user
    user_class: Blogger\BlogBundle\Entity\User

security.yml:

security:
    encoders:
        Symfony\Component\Security\Core\User\User: plaintext
        FOS\UserBundle\Model\UserInterface: sha512

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        in_memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
        fos_user:
            id: fos_user.user_manager

    firewalls:
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        fos_user:
            pattern:    ^/
            provider:   fos_user
            form_login:
                check_path: /login_check
                login_path: /login
            logout:
                path:   /logout
                target: /
            anonymous: ~

    access_control:
        - { path: /secured/admin, roles: ROLE_ADMIN }
        - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, roles: IS_AUTHENTICATED_ANONYMOUSLY }

UPDATE

Stack trace:

https://i.sstatic.net/vsGwF.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

随梦而飞# 2025-01-03 11:01:53

确保为 FOSUserBundle 指定版本。存储库头与 Symfony 头对齐,而不是 2.0.9。

[FOSUserBundle]
    git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
    target=/bundles/FOS/UserBundle
    version=1.0.0

Make sure you specify a version for FOSUserBundle. The repository head is aligned with Symfony head, not 2.0.9.

[FOSUserBundle]
    git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
    target=/bundles/FOS/UserBundle
    version=1.0.0
风轻花落早 2025-01-03 11:01:53

如果您要更新 FOSUserBundle(或任何与此相关的捆绑包),您需要确保模仿 FOSUserBundle 中对您覆盖的任何文件所做的更改。

在我的特定情况下,在 RegistrationController FOSUserBundle 中,在authenticateUser 方法中将值从 security.user_checker 更改为 fos_user.user_checker,因此我在控制器中进行了相同的更改。

每次更新供应商时,您都需要确保您在捆绑包中覆盖的文件(控制器、服务等)不依赖于已删除的服务类或方法。

If you're updating FOSUserBundle (or any bundle for that matter) you need to make sure you mimic changes made in the FOSUserBundle to any files you overwrite.

In my particular case, in the RegistrationController FOSUserBundle changed a value from security.user_checker to fos_user.user_checker in the authenticateUser method, so I made the same change in my controller.

Every time you do an update of the vendors, you need to make sure files (controllers, services etc) you're overwriting in your bundle are not depending on a service class or method that has been removed.

您的好友蓝忘机已上羡 2025-01-03 11:01:53

您注册服务正确吗?
或者也许您忘记了为此服务添加路由?

Do you register services right ?
Or maybe You forgot add a routing for this service ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文