将Symfony从3.4升级到4.4(无flex)获得服务或别名后已被删除或嵌入容器时,

发布于 2025-02-08 11:06:59 字数 1822 浏览 1 评论 0原文

在将Symfony从3.4更新为4.4(无flex)后,我遇到了此错误“ Tactician.CommandBus”服务或别名已被删除或在集装箱被编译时已删除或嵌入。您应该将其公开,或者停止直接使用容器并使用依赖注入。

di-Extra-Bundle向控制器注入代表

class MngmtController extends AbstractFOSRestController
{
   /**
     * @var CommandBus
     */
    private $commandBus;

    /**
     * @var CommandBus
     */
    private $mngmtCommandBus;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @var MngmtService
     */
    private $mngmtService;

    /**
     * @param ContainerInterface $container
     * @param CommandBus         $commandBus
     * @param CommandBus         $mngmtCommandBus
     * @param LoggerInterface    $logger
     * @param MngmtService       $mngmtService
     *
     * @DI\InjectParams({
     *     "container" = @DI\Inject("service_container"),
     *     "commandBus" = @DI\Inject("tactician.commandbus"),
     *     "mngmtCommandBus" = @DI\Inject("tactician.commandbus.mngmt"),
     *     "logger" = @DI\Inject("monolog.logger"),
     *     "mngmtService" = @DI\Inject("app.services.mngmt_service"),
     * })
     */
    public function __construct(
        ContainerInterface $container,
        CommandBus $commandBus,
        CommandBus $mngmtCommandBus,
        LoggerInterface $logger
        MngmtService $mngmtService,
    ) {
        $this->container = $container;
        $this->commandBus = $commandBus;
        $this->mngmtCommandBus = $mngmtCommandBus;
        $this->logger = $logger;
        $this->mngmtService = $mngmtService;
    }

   _defaults:
        public: true
   
    League\Tactician\CommandBus:
        alias: 'tactician.commandbus'
        public: true
    
    Psr\Log\LoggerInterface:
        alias: 'monolog.logger'
        public: true

我正在使用JMS / 错误

After updating symfony from 3.4 to 4.4(without flex) i am getting this error The "tactician.commandbus" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

I am injecting depnedeicies to controller using jms/di-extra-bundle

class MngmtController extends AbstractFOSRestController
{
   /**
     * @var CommandBus
     */
    private $commandBus;

    /**
     * @var CommandBus
     */
    private $mngmtCommandBus;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * @var MngmtService
     */
    private $mngmtService;

    /**
     * @param ContainerInterface $container
     * @param CommandBus         $commandBus
     * @param CommandBus         $mngmtCommandBus
     * @param LoggerInterface    $logger
     * @param MngmtService       $mngmtService
     *
     * @DI\InjectParams({
     *     "container" = @DI\Inject("service_container"),
     *     "commandBus" = @DI\Inject("tactician.commandbus"),
     *     "mngmtCommandBus" = @DI\Inject("tactician.commandbus.mngmt"),
     *     "logger" = @DI\Inject("monolog.logger"),
     *     "mngmtService" = @DI\Inject("app.services.mngmt_service"),
     * })
     */
    public function __construct(
        ContainerInterface $container,
        CommandBus $commandBus,
        CommandBus $mngmtCommandBus,
        LoggerInterface $logger
        MngmtService $mngmtService,
    ) {
        $this->container = $container;
        $this->commandBus = $commandBus;
        $this->mngmtCommandBus = $mngmtCommandBus;
        $this->logger = $logger;
        $this->mngmtService = $mngmtService;
    }

I have tried adding this in services.yml, but didn't help

   _defaults:
        public: true
   
    League\Tactician\CommandBus:
        alias: 'tactician.commandbus'
        public: true
    
    Psr\Log\LoggerInterface:
        alias: 'monolog.logger'
        public: true

I am following older directory structure not updated to sf4/flex directory structure, Please help me with the above error

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文