Answers for "run command from controller symfony"

PHP
0

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',
            // (optional) define the value of command arguments
            'fooArgument' => 'barValue',
            // (optional) pass options to the command
            '--message-limit' => $messages,
        ]);
        // You can use NullOutput() if you don't need the output
        $output = new BufferedOutput();
        $application->run($input, $output);
        // return the output, don't use if you used NullOutput()
        $content = $output->fetch();
Posted by: Guest on May-05-2021

Code answers related to "run command from controller symfony"

Browse Popular Code Answers by Language