我安装了 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 }