【问题标题】:The service "form.type.users" has a dependency on a non-existent service "security.context"服务“form.type.users”依赖于不存在的服务“security.context”
【发布时间】:2019-07-08 17:39:27
【问题描述】:

我在我的项目中使用了 symfony2.8。我这样配置config.yml

fos_user:

db_driver: orm

firewall_name:主要

user_class:视频\IntelligenceBundle\Entity\Users

来自_email:

    address: you@example.com

    sender_name: example

parameter.yml 这样:

参数:

mongodb_server: "mongodb://xxx.xxx.xxx.xxx:xxxx"

database_host: xxx.xxx.xxx.xxx

database_port: xxxx

database_name: dbtest

mailer_transport: smtp

mailer_host: mail.supremecenter.com

mailer_user: test@example.pro

mailer_password: test

database_user: root

database_password: null

但是当我运行这个命令时:

php app/console doctrine:schema:update --force

我收到此错误:

 The service "form.type.users" has a dependency on a non-existent service "security.context".

服务:

form.type.users:

    class: Video\IntelligenceBundle\Form\UsersType

    arguments: ["@security.context"]

    tags:

        - { name: form.type, alias: users_type }

【问题讨论】:

  • 请不要在图片中分享文字。另外,form.type.users服务的定义是什么?
  • 谢谢@NicoHaase,这是定义:form.type.users: class: Video\IntelligenceBundle\Form\UsersType arguments: ["@security.context"] tags: - { name: form .type,别名:users_type }

标签: php symfony security console doctrine


【解决方案1】:

查看https://symfony.com/blog/new-in-symfony-2-6-security-component-improvements 的升级说明 - 该服务自 Symfony 2.6 起已被弃用,您需要检查哪些部分(令牌存储服务 security.token_storage 允许您访问当前登录的用户,或者用于检查权限的服务security.authorization_checker)实际上需要在您的表单中。

但是,如果您使用的是 Symfony 2.8,这不应该是一个障碍:您确定您真的使用的是那个版本而不是更新的版本吗?尽管如此,将代码重构为这些新服务应该没有错

【讨论】:

    猜你喜欢
    • 2022-11-10
    • 2017-03-21
    • 2019-09-28
    • 2015-05-29
    • 2018-07-22
    • 2018-01-16
    • 2018-05-18
    • 2016-10-11
    • 1970-01-01
    相关资源
    最近更新 更多