When I submit my form it reads a file of thousands lines and executes some tasks.
I have created a symfony command to do that.
Once my form is submitted and validated I pass the command the required arguments.
The different tasks are executed but not asynchronously.
I cannot go to another page before the end of the process.
The Symfony controller
<?php
namespace App/Controller
class FileConfigController
{
public function loadFile(KernelInterface $kernel) {
// ...
if ($form->isSubmitted() && $form->isValid()) {
$name = 'Test.xls';
$application = new Application($kernel);
$application->setAutoExit(false);
$application->setCatchExceptions(true);
$input = new ArrayInput([
'command' => 'app:load-file',
'name' = $name,
'type' = $form['type']->getData()
]);
$application->run($input, new NullOutput());
}
}
The Symfony command script
<?php
namespace App/Command
class FileCommand extends Command
{
protected static $defaultName = 'app:load-file';
protected function configure() {}
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
$type = $input->getArgument('type');
// Script
}
}