php脚本中的循环以星号执行

php脚本中的循环以星号执行,php,while-loop,asterisk,Php,While Loop,Asterisk,我的想法是,我想在Asterisk的拨号计划中执行一个PHP脚本。它的工作原理类似于一个deamon/进程,它从星号中获取值并对其进行处理。但是,当我执行系统(php script.php)命令时,Asterisk停止,并且不会进入下一个拨号计划步骤。原因是,我相信script.php内部有“while(1){…}”循环,星号等待它的结束 您能否帮助我并向我展示一些解决方案,如何运行外部“php循环”脚本并一次性完成extensions.conf步骤 extensions.conf script

我的想法是,我想在Asterisk的拨号计划中执行一个PHP脚本。它的工作原理类似于一个deamon/进程,它从星号中获取值并对其进行处理。但是,当我执行系统(php script.php)命令时,Asterisk停止,并且不会进入下一个拨号计划步骤。原因是,我相信script.php内部有“while(1){…}”循环,星号等待它的结束

您能否帮助我并向我展示一些解决方案,如何运行外部“php循环”脚本并一次性完成extensions.conf步骤

extensions.conf

script.php

#/usr/bin/php
因此,正如您所看到的,这个想法很简单:用“循环”启动php脚本,同时在[internal]上下文中从底部步骤执行其他操作。 如何处理?因为Asterisk等待script.php执行结束,然后进入下一步


谢谢大家!

星号中的Agi被阻塞。Dialplan执行将等待agi死亡后再继续。如果你想让你的agi在不考虑拨号计划的情况下运行,请查看Fastagi,它是一个agi deamon,你可以通过套接字连接到它(它的长寿命,与星号无关)。在呼叫agi之前,请不要忘记在拨号计划中设置${AGISIGUP}=no

有关AGI的示例,请参阅并查看许多模块中包含的一些脚本

[internal]
exten => 100,1,Set(CallerId=${CALLERID(num)}) ;get number
exten => 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 => 100,n,Dial(SIP/100)
exten => 100,n,Hangup()
#!/usr/bin/php
<?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;
  */
  }
?>