I'm building a symfony4 webapp. I have a command that I can run like a charm directly in cli :
php bin/console app:analysis-file 4
But when I try to exec if directly from a Controller via :
$process = new Process('php bin/console app:analysis-file '.
$bankStatement->getId());
$process->run();
Then $process->getOutput() return "Could not open input file bin/console".
This is the Command Class :
class AnalysisFileCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('app:analysis-file')
->addArgument('file_id', InputArgument::REQUIRED);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$entityManager = $this->getContainer()->get('doctrine')->getEntityManager();
$bankStatement = $entityManager->getRepository(BankStatement::class)->find($input->getArgument("file_id"));
$bankStatement->setStatus(BankStatement::ANALYZING);
$entityManager->persist($bankStatement);
$entityManager->flush();
}
}