我安装了如下所述的FOS Bundle: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md
使用composer安装并设置用户类后,我总是得到:
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "fos_user.security.login_manager" has a dependency on a non-exi
stent service "security.context".
我检查了路径的存在,并且fosuserbundle中包含了contextinterface ... 使用控制台始终以相同的错误中止。 任何人吗?
我在appKernel中启用了捆绑包(安全捆绑包也被激活了):
...
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
...
new FOS\UserBundle\FOSUserBundle(),
...
我将配置添加到config.yml:
# fos UserBundle config
fos_user:
db_driver: orm
firewall_name: main
user_class: SDDB\MainBundle\Entity\User
我扩展了routing.yml:
# USER AUTH STUFF
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
和security.yml:
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 }
答案 0 :(得分:1)
好的,我在FOS Bundle的开发者的帮助下找到了解决方案。
如果你有一个类似的问题,请查看一些基本内容:
我在第(4)点的包含行中有一个愚蠢的错字......
答案 1 :(得分:1)
添加:
- {resource:security.yml}到主config.yml的导入部分,它解决了我的问题
答案 2 :(得分:0)