Symfony 4自动接线工作不正常

Symfony 4自动接线工作不正常,symfony,symfony4,beanstalkd,Symfony,Symfony4,Beanstalkd,以下是上下文: 已安装beanstalk捆绑包,其中包含composer“composer需要leezy/pheanstalk捆绑包” 我试图在命令内部使用,但出现了以下错误 无法自动连线服务“App\Command\Worker\ProcessParserCommand”:方法“\uu construct()”的参数“$pheanstalk”引用接口“pheanstalk\Contract\PheanstalkInterface”,但没有这样的 服务存在。您可能应该将此接口别名为现有的“lee

以下是上下文:

  • 已安装beanstalk捆绑包,其中包含composer“composer需要leezy/pheanstalk捆绑包”

  • 我试图在命令内部使用,但出现了以下错误

  • 无法自动连线服务“App\Command\Worker\ProcessParserCommand”:方法“\uu construct()”的参数“$pheanstalk”引用接口“pheanstalk\Contract\PheanstalkInterface”,但没有这样的
    服务存在。您可能应该将此接口别名为现有的“leezy.pheanstalk.proxy.default”服务


    事实证明,这是一个欺骗性的错误信息

    通常,当您收到“接口不存在,可能是别名SomeService”消息时,这意味着需要将接口显式定义为别名:

    # config/services.yaml
    Pheanstalk\Contract\PheanstalkInterface:
        alias: 'leezy.pheanstalk.proxy.default'
    
    但是在这种情况下,当这样做让您通过接口错误时,会产生一个新的“构造函数参数太少”错误

    浏览一下捆绑包的文档,就会发现您需要进行一些配置才能真正生成pheanstalk实例。composer require命令足够智能,可以将bundle添加到bundles.php文件中,但不会创建配置文件。因此,根据文档添加配置文件:

    # config/packages/leezy_pheanstalk.yaml
    leezy_pheanstalk:
        pheanstalks:
           primary:
               server: beanstalkd.domain.tld
               default: true
    

    还有普雷斯托。错误消失了。另外,config/services.yaml中的别名不再需要,如果您添加了它,应该将其删除。

    那么,当您按照错误消息中的提示操作时,会发生什么呢?仍然不知道该怎么办,由于my services.yml文件是标准配置,我应该能够使用它考虑使用添加到services.yml文件中的别名定义更新您的问题。键入console
    bin/console debug:autowiring | grep pheanstalk interface
    。你有什么结果吗?如果没有,请尝试清除缓存
    bin/console cache:pool:clear
    。运行调试后:自动连线结果为>>>这是LeezyPheanstalkBundle的数据采集器。Leezy\PheanstalkBundle\DataCollector\PheanstalkDataCollector(Leezy.pheanstalk.data\u collector)Leezy\PheanstalkBundle\PheanstalkLocator(Leezy.pheanstalk.pheanstalk\u locator)
    # config/packages/leezy_pheanstalk.yaml
    leezy_pheanstalk:
        pheanstalks:
           primary:
               server: beanstalkd.domain.tld
               default: true