rescobar
rescobar

Reputation: 1305

How to Call a Command from a Controller and use Debug mode?

If I execute a task using the console I can add --no-debug:

php app/console app:task-name web-user --no-debug

This is the function inside Controller that call the task 'task-name ' and it works properly

public function generateSomethingAction() {
    $kernel = $this->get('kernel');
    $application = new Application($kernel);
    $application->setAutoExit(false);
    $input = new ArrayInput(array(
        'command' => 'app:task-name'
    ));
    $output = new BufferedOutput();
    $application->run($input, $output);
    ......

I would like to know if is possible to add --no-debug if I call the command from a controller?

Upvotes: 0

Views: 461

Answers (1)

yivi
yivi

Reputation: 47369

To pass additional parameters that don't need values, you can just add them to the ArrayInput array with a value of "true".

E.g.

$input = new ArrayInput([
        'command'     => 'app:task-name',
        '--yell'      => true,
        '--no-debug'  => true,
    ]);

Upvotes: 2

Related Questions