2015-04-02 30 views
0

我工作的一个Symfony2的Command一个空的名字,我有一个错误,当我尝试在prod环境中运行的命令,但它在dev完美地工作:的Symfony命令在生产environement

一切很好,如果我运行:

php app/console mycommand:start

当我运行

php app/console mycommand:start --env=prod

我得到这个错误:

[LogicException]                    
The command defined in "NameSpace\Of\MyClassCommand" cannot have an empty name. 

命令定义:

services: 
    my_service.command: 
     class: NameSpace\Of\MyClassCommand 
     arguments: 
     name: mycommand:start 
     tags: 
     - { name: console.command } 

命令:

class MyClassCommand extends Command 
{ 

    /** 
    * @param InputInterface $input 
    * @param OutputInterface $output 
    */ 
    protected function execute(InputInterface $input, OutputInterface $output) 
    { 
     // logic 
    } 

    ... 
} 

正如你可能会注意到,我不超载__constructconfigure方法。我尝试过但没有改变任何东西。同样的事情,如果我清理缓存。

有没有人有一个想法是什么可能是proddev环境之间的差异,导致这个问题?

谢谢

+0

您是否尝试清除缓存? – 2015-04-02 19:01:13

+0

是的,但结果相同 – 2015-04-02 19:29:05

+0

试着把命令名放在引号中:''mycommand:start''只是为了安全起见(':'可能会干扰某些事情) – Im0rtality 2015-04-02 19:36:06

回答

0

我终于找到了解决方案,Ruslan你是对的:清除缓存。 但我不得不手动核实缓存文件夹,cache:clear命令是不够的。

0

清除缓存对我无效。我需要声明基类为abstract class以提示Symfony不要将其注册为命令。

abstract class BaseCommand { 
    ... 
}