call command from controller symfony code example
Example: run command from controller symfony
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\HttpKernel\KernelInterface;
$application = new Application($kernel);
$application->setAutoExit(false);
$input = new ArrayInput([
'command' => 'swiftmailer:spool:send',
'fooArgument' => 'barValue',
'--message-limit' => $messages,
]);
$output = new BufferedOutput();
$application->run($input, $output);
$content = $output->fetch();