“xxx”命名空间中没有定义命令

Leo*_*rov 6 php symfony

我在 symfony3 上有一个大项目。在这个项目中,我有 ProjectFrameworkBundle。

项目/FrameworkBundle/Console/Command.php

abstract class Command extends ContainerAwareCommand
{
    //...

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // do some regular staff
        $exitCode = $this->executeCommand($input, $output);
        // do some regular staff
    }

    abstract protected function executeCommand(InputInterface $input, OutputInterface $output);

    //...
}
Run Code Online (Sandbox Code Playgroud)

如果我要从 Command 类扩展任何命令,它将正常工作(已测试)。

但是,我还有一个包

项目/FrameworkQueue/控制台/Command.php

use Project\FrameworkBundle\Console\Command as BaseCommand;
abstract class Command extends BaseCommand
{
    // ...
    protected function executeCommand(InputInterface $input, OutputInterface $output)
    {
        // do some regular staff
        $exitCode = $this->executeJob($input, $output);
        // do some regular staff
    }

    abstract protected function executeJob(InputInterface $input, OutputInterface $output);

    // ...
}
Run Code Online (Sandbox Code Playgroud)

因此,当我将 amy Command 从更改extends Project\FrameworkBundle\Console\Commandextends Project\QueueBundle\Console\Command它时,它会从命令列表中隐藏。我试图从executeCommandin 中删除所有员工QueueBundle,但这对我没有帮助。但是如果我在这个命令中的 php 代码中犯了任何错误,我就会看到异常。

什么错?我的错误在哪里或者这是一个错误。我在哪里可以找到收集和检查可用命令的 symfony 代码?

谢谢!

PS 问题不在于文件或类命名 - 我检查了很多次。当然,当我改变父类时,我改变了函数名称。

Leo*_*rov 3

问题出__constructQueueBundle\Console\Command. 如果您尝试这样做:

public function __construct($name)
{
    parent::__construct($name);
}
Run Code Online (Sandbox Code Playgroud)

... 不起作用。我不知道为什么,但我将一些逻辑从这里移至“执行之前”操作。

谢谢大家!