的Symfony命令在生产environement
问题描述:
我工作的一个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
}
...
}
正如你可能会注意到,我不超载__construct
或configure
方法。我尝试过但没有改变任何东西。同样的事情,如果我清理缓存。
有没有人有一个想法是什么可能是prod
和dev
环境之间的差异,导致这个问题?
谢谢
答
我终于找到了解决方案,Ruslan你是对的:清除缓存。 但我不得不手动核实缓存文件夹,cache:clear
命令是不够的。
答
清除缓存对我无效。我需要声明基类为abstract class
以提示Symfony不要将其注册为命令。
abstract class BaseCommand {
...
}
您是否尝试清除缓存? – 2015-04-02 19:01:13
是的,但结果相同 – 2015-04-02 19:29:05
试着把命令名放在引号中:''mycommand:start''只是为了安全起见(':'可能会干扰某些事情) – Im0rtality 2015-04-02 19:36:06