run command from controller symfony

Solutions on MaxInterview for run command from controller symfony by the best coders in the world

showing results for - "run command from controller symfony"
Antonio
26 Jul 2017
1use Symfony\Bundle\FrameworkBundle\Console\Application;
2use Symfony\Component\HttpKernel\KernelInterface;
3// *****
4        $application = new Application($kernel);
5        $application->setAutoExit(false);
6        $input = new ArrayInput([
7            'command' => 'swiftmailer:spool:send',
8            // (optional) define the value of command arguments
9            'fooArgument' => 'barValue',
10            // (optional) pass options to the command
11            '--message-limit' => $messages,
12        ]);
13        // You can use NullOutput() if you don't need the output
14        $output = new BufferedOutput();
15        $application->run($input, $output);
16        // return the output, don't use if you used NullOutput()
17        $content = $output->fetch();