我在src/CollaboratorsBundle/Command中创建了一个新类,将其命名为GenerateFormRemindersCommand.php并将以下代码放入其中:
<?php
namespace Myproject\CollaboratorsBundle\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
class GenerateFormRemindersCommand extends ContainerAwareCommand{
protected function configure() {
$this->setName("generate:formReminders")
->setDescription('Send reminders by email to all collaborators with unanswered forms');
}
protected function execute(InputInterface $input, OutputInterface $output) {
//some code
}
}
Run Code Online (Sandbox Code Playgroud)
执行时,我收到以下消息:
$ php app/console generate:formReminders
[InvalidArgumentException]
Command "generate:formReminders" is not defined.
Run Code Online (Sandbox Code Playgroud)
我已经在我的AppKernel.php文件中检查了我的捆绑包已在其中注册了.
我尝试过添加parent:configure(); 到configure方法但没有任何结果.
我已经创建了一些其他正常工作的自定义命令.在这种情况下,我不明白我做错了什么.你呢 ?
提前致谢
Via*_*lov 61
我有同样的麻烦,因为我没有"命令"后缀命名文件.您必须将文件命名为"GenerateFormRemindersCommand.php".
归档时间: |
|
查看次数: |
12821 次 |
最近记录: |