Running a background task using Symfony Process without having to wait for the process to finish

后端 未结 5 1516
隐瞒了意图╮
隐瞒了意图╮ 2021-02-12 22:30

After a user submits a form, I want to render a view file, and right after that I want to initiate a background task to process five MS Excel files (each may have up to 2000 row

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 23:25

    I am a bit late to the game, but I just found a solution for this problem using the fromShellCommandLine() method:

    use Symfony\Component\Process\Process;
    
    Process::fromShellCommandline('/usr/bin/php /var/www/bin/console hello:world')->start();
    

    This way it is possible to start a new process/run a command asynchronously.

提交回复
热议问题