How to run several PHP script in background?


I’m wonderring if there is any way to run php script in backgroung (as “multithred”)

I tryied severall way but nothing seem to work :frowning:

Could say me where i’m wrong ?

Methode 1 using socket:

My code:

    $url = 'test.php'; 
  	$errno = '';
  	$errstr = '';
  	$fp = fsockopen($server, $port, $errno, $errstr, $conn_timeout);
  	if (!$fp) {
  	   echo "$errstr ($errno)<br />\n";
  	   return false;
  	$out = "GET $url HTTP/1.1\r\n";
  	$out .= "Host: $server\r\n";
  	$out .= "Connection: Close\r\n\r\n";
  	stream_set_blocking($fp, false);
  	stream_set_timeout($fp, $rw_timeout);
  	fwrite($fp, $out);   

The retunr is

Failed to parse address “localhost” (0)

I tryed with “http://heserver/” as host name but i got

Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (123344144)

Methode 2 using CURL:

My code:

    $curlUrl = 'http://heserver/test.php';

     $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $curlUrl);
      curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
      curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1);
         $error_message = curl_error($ch);
         echo "<br>erreur:" . $error_message;

the received error is:

Could not resolve host: heserver; Host not found

Actualy i got several long task (php script) to run in background, i’m aware to any way (but ajax) to dot it in exeputput.

Thanks in advance


Same as another post: CURL can’t access the http://heserver protocol. In ExeOutput 2, we have worked on a new feature called timers, which allow run several PHP scripts in the background at regular intervals. I think it will solve your problem. Until that, why not try AJAX call?

Yes timer sound great, will see :wink:

Well actualy my app is using asyncronous ajax call to call the PHP scripts
But it slow dow the app, so i would like to make real multitheading like soket.

thanks anyway

Timer sounds great, yes. Any updates on when we can expect ExeOutput 2?

We are still working on it. It’s a major rewrite since Chromium has been completely replaced by CEF3 and there is also the new interface editor.