问题描述
我安装了如下所述的FOS捆绑包: /Resources/doc/index.md
与作曲家安装并设置用户类,我总是得到:
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] The service "fos_user.security.login_manager" has a dependency on a non-exi stent service "security.context".
我检查了路径的存在,并且有fosuserbundle中包含的上下文表... 使用控制台始终以相同的错误中止. 有人吗?
我启用了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
我扩展了路由:
# 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 }
推荐答案
好的,我在FOS捆绑包的开发人员的帮助下找到了解决方案.
如果您有一个类似的问题,请通过一些基本内容:
- FOS捆绑版版本适合您的Symfony版本?
- 安全捆绑包是否适当安装?
- 它是否在Appkernel中激活?
- 是否有一个配置文件(security.yml)?
- 它是否正确地插入了(main)config.yml?
我在(4)...
点的包含行中有一个哑巴错字其他推荐答案
添加:
- {resource:security.yml}到主config.yml中的导入部分,它解决了我的问题
其他推荐答案
- 检查服务文件是否存在(SecurityBundle \ Resources \ Config \ Config \ Security.xml)
- 检查服务文件是否已加载(SecurityBundle \ disterencyInjection \ SecurityExtension.php)
问题描述
I installed the FOS Bundle like mentioned in: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md
After installation with composer and setting up the user class i always get:
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] The service "fos_user.security.login_manager" has a dependency on a non-exi stent service "security.context".
I checked the existence of the path and there is the contextinterface that is included in the fosuserbundle... Using the console always aborts with the same error. Anyone?
I enabled the bundle in appKernel (where the security bundle also is activated):
... new Symfony\Bundle\SecurityBundle\SecurityBundle(), ... new FOS\UserBundle\FOSUserBundle(), ...
I added the config to the config.yml:
# fos UserBundle config fos_user: db_driver: orm firewall_name: main user_class: SDDB\MainBundle\Entity\User
I extended the 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
and the 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 }
推荐答案
Ok i found the solution with help of a developer of FOS Bundle.
If you have a simmilar problem go through some basic stuff:
- Is the FOS Bundle version fitting for your Symfony version?
- Is security bundle proper installed?
- Is it activated in the appkernel?
- Is there a configuration file for it (security.yml)?
- Is it inlcuded properly in the (main)config.yml?
I had a dumb typo in the include line at point (4)...
其他推荐答案
Add :
- { resource: security.yml } to the import section in the main config.yml, it solved the problem for me
其他推荐答案
- Check whether the service file exists (SecurityBundle\Resources\config\security.xml)
- Check whether the service file is loaded (SecurityBundle\DependencyInjection\SecurityExtension.php)