Asynchronous shell exec in PHP

前端 未结 13 2019

I\'ve got a PHP script that needs to invoke a shell script but doesn\'t care at all about the output. The shell script makes a number of SOAP calls and is slow to complete,

13条回答
  •  忘了有多久
    2020-11-22 01:08

    I also found Symfony Process Component useful for this.

    use Symfony\Component\Process\Process;
    
    $process = new Process('ls -lsa');
    // ... run process in background
    $process->start();
    
    // ... do other things
    
    // ... if you need to wait
    $process->wait();
    
    // ... do things after the process has finished
    

    See how it works in its GitHub repo.

提交回复
热议问题