Anjana Silva
Anjana Silva

Reputation: 9221

How to execute command doctrine:generate:entities within the system?

I am having a strange error. I am trying to execute Symfony doctrine console commands within the system. I did managed to execute 'doctrine:mapping:import' within the system without having any issue. Look at my code below,

protected function execute(InputInterface $input, OutputInterface $output)
{
    $import_arguments = array(
        '--force' => true,
        'bundle' => 'TestConsoleCommandBundle',
        'mapping-type' => 'yml',
    );
    $input = new ArrayInput($import_arguments);
    $command = $this->getApplication()->find('doctrine:mapping:import');
    $command->run($input, $output);  
}

But when I execute 'doctrine:generate:entities' command within the system it says RuntimeException , Not enough arguments. As far as I know, only 'name' is the only compulsory arguments this command looks for. Look at my code below,

protected function execute(InputInterface $input, OutputInterface $output)
{
    $command = $this->getApplication()->find('doctrine:generate:entities');   
        $arguments = array(
            '--path' => "src/ESERV/MAIN/ActivityBundle/Entity",
            '--no-backup' => 'true',
            'name' => 'ESERVMAINActivityBundle'

        );
        $input = new ArrayInput($arguments);
        $command->run($input, $output);  
}

I am surprised here because such a straightforward thing seems to be not working. Can anyone please please tell me what I am possibly missing in here.

Many thanks in advance.

Upvotes: 0

Views: 2977

Answers (1)

qooplmao
qooplmao

Reputation: 17759

The first argument needs to be the command that you are calling.

Taken from the docs..

protected function execute(InputInterface $input, OutputInterface $output)
{
    $command = $this->getApplication()->find('demo:greet');

    $arguments = array(
        'command' => 'demo:greet',
        'name'    => 'Fabien',
        '--yell'  => true,
    );

    $input = new ArrayInput($arguments);
    $returnCode = $command->run($input, $output);

    // ...
}

Upvotes: 2

Related Questions