0
首先,我想要做的是學習用的文檔 http://symfony.com/doc/current/cookbook/console/console_command.html控制檯命令:找到該文件,但該類不在其中,類名或命名空間可能有拼寫錯誤。
我想複製正是被文檔
這上完成創建自己的控制檯命令是我一直走到這一步,
<?
// src/Gabriel/LiveLoginBundle/Command/GreetCommand.php
namespace Gabriel\LiveLoginBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class GreetCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('demo:greet')
->setDescription('Greet someone')
->addArgument('name', InputArgument::OPTIONAL, 'Who do you want to greet?')
->addOption('yell', null, InputOption::VALUE_NONE, 'If set, the task will yell in uppercase letters');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
if ($name)
{
$text = 'Hello '.$name;
}
else
{
$text = 'Hello';
}
if ($input->getOption('yell'))
{
$text = strtoupper($text);
}
$output->writeln($text);
}
}
但由於某些原因,它拋出這個錯誤,它似乎無法找到類
找到該文件但該類不在其中,類名或 命名空間可能有錯字。
PS:已經嘗試刪除緩存
嘗試使用正確的<?php;) – ElPoney
冬青的廢話,它的作品 – user3531149
發佈這個答案 – user3531149