0

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?

2
  • 1
    Try it - and if it doesn't work, then ask a different question? Commented Jan 20, 2017 at 19:40
  • You might be better off moving the functionality that generates the json into it's own service and then accessing the service from either the command or the controller. That get's rid of all the Application nonsense. Commented Jan 20, 2017 at 20:20

1 Answer 1

2

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,
    ]);
Sign up to request clarification or add additional context in comments.

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.