I am still pretty new to Symfony. I have set up 'n demonstration of some of the components that I have written on my online portfolio and I want this demo data to be cleared every two hours. On my web server I want to set a cron job like so:
php app/console portfolio:wipe
I have created app/src/MyFreelancer/PortfolioBundle/Command/WipeCommand.php (PortfolioBundle is registered in AppKernel.php) and here is its contents (copied exactly from http://symfony.com/doc/current/cookbook/console/console_command.html and changed the namespace and command name).
<?php
namespace MyFreelancer\PortfolioBundle\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 WipeCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('maintenance: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);
}
}
?>
However, when I run
php app/console portfolio:wipe test
Instead of getting "Hello test", I get
There are no commands defined in the "portfolio" namespace.
Any help would be appreciated.