title: loop in php script executes by asterisk
body: <p>My idea is that I want to execute a PHP script in Asterisk's dial-plan. It works like a deamon/process that gets values from the Asterisk and does something with them. But when I do the <strong>system(php script.php)</strong> command Asterisk stops and does not go to the next dial-plan step. The reason is that, I believe, the <em>script.php</em> has "while(1) {...}" loop inside and Asterisk waits for its end...</p>
  
  <p>Could you help me and show me some solution how to run external "php-loop" script and go through extensions.conf steps at one time?</p>
  
  <p><em>extensions.conf</em></p>
  
  <pre><code>[internal]
  exten =&gt; 100,1,Set(CallerId=${CALLERID(num)}) ;get number
  exten =&gt; 100,n,System(php script.php ${CallerId}) ;execute php script with argv[1]
  ;now the script.php should run at the background and below part
  ;should be execute like in ordinary context
  exten =&gt; 100,n,Dial(SIP/100)
  exten =&gt; 100,n,Hangup()
  </code></pre>
  
  <p><em>script.php</em></p>
  
  <pre><code>#!/usr/bin/php
  &lt;?php
    $num = argv[1]; //the value from [internal] in the extensions.conf
    while(1) { //start the loop
    /*
     * do something in the infinite loop and END it IF something happen
     * e.g. $someVal == 9999;
    */
    }
  ?&gt;
  </code></pre>
  
  <p>So, as you can see the idea is simple: start the php script with the 'loop' and in meantime do something else from the bottom steps in the [internal] context.
  How to handle it? Because Asterisk waits for the end of the <em>script.php</em> execution and then he goes to the next step.</p>
  
  <p>Thank you!</p>