I am using symfony console component
When I run this command by console
php application.php
Then this command give me this error
PHP Fatal error: Class 'GreetCommand' not found in /var/www/cli/application.php on line 11
I configured all setting according to this link
http://symfony.com/doc/current/components/console/introduction.html
My application.php file code
<?php
// application.php
require __DIR__.'/vendor/autoload.php';
//use GreetCommand;
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new GreetCommand());
$application->run();
And My Greet Command exist in same location of the application.php file Code is:
<?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);
}
}
So please help me what is the problem in my application.php file when executing this command by using symfony console component