0

I'm trying to create a custom console command for my project so i thought I'll first try it out with the example given in the symfony site, I have provided the steps it took to reach this far,

Step 1: Added  "symfony/console": "2.3.*@dev", to composer.json.
Step 2: Updated composer.

The code written for the command is given below

class Sendgcmfuctions 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);
}
}

On running "php app/console demo:greet" the following error is produced

PHP Fatal error:  Class 'Doctrine\ORM\Tools\Console\Command\ClearCache\QueryRegionCommand' not found in /var/www/MobpazAdmin/vendor/doctrine/doctrine-bundle/Doctrine/Bundle/DoctrineBundle/Command/Proxy/QueryRegionCacheDoctrineCommand.php on line 29

The "Sendgcmfuctions" is inside a Command folder inside my bundle. Please tell me the mistake commited while doing this

2
  • What version of Symfony do you use in this project? Commented Jan 27, 2014 at 9:03
  • Symfony version 2.3.10 Commented Jan 27, 2014 at 9:14

3 Answers 3

2

it seems to be an issue of doctrine's latest bundle. try use another stable version.

"doctrine/doctrine-bundle": "1.2.0" works for us

Sign up to request clarification or add additional context in comments.

1 Comment

I changed this now the fatal error has been removed now there is an InvalidArgumentException There are no commands defined in the "demo" namespace.
0

Try to use next require in composer.json:

"symfony/console": "~2.3"

It's probably an vendor error. Try to use later stable version

3 Comments

I'm still stuck with the same problem, was not able to resolve it.
maybe try to "v2.3.9" or v2.3.0
yes i did this, still no use, may be its something else. Is there anything to add in appkernel.php or any other file.
0

I did as Max suggested and the installation went smoothly, the exception

[InvalidArgumentException]
There are no commands defined in the "demo" namespace.

was due to a naming problem had to add a suffix of to the class name as Command

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.