我正在使用symfony控制台组件
当我通过控制台运行此命令时
php application.php
然后这个命令给我这个错误
PHP致命错误:Class' GreetCommand'找不到 第11行/var/www/cli/application.php
我根据此链接配置了所有设置
http://symfony.com/doc/current/components/console/introduction.html
我的application.php文件代码
<?php
// application.php
require __DIR__.'/vendor/autoload.php';
//use GreetCommand;
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new GreetCommand());
$application->run();
我的Greet命令存在于application.php文件的相同位置 代码是:
<?php
//namespace Command;
use Symfony\Component\Console\Command\Command;
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 Command
{
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);
}
}
所以请帮助我使用symfony控制台组件执行此命令时application.php文件中的问题是什么