通过PHP启动.php脚本异步并回答请求

I try to start a .php script asynchron from an other php script.

if (substr(php_uname(), 0, 7) == "Windows"){
    $cmd = "start /B php AsynchronDownload.php fileids=".$this->header->queryParams['ids'] . " uid=".$this->header->tokenData->uId . " groupId=".$this->header->tokenData->groupId . " timestamp=".$this->header->tokenData->timestamp . " state=".$this->header->tokenData->state. " token=".$this->header->tokenData->token;
    pclose(popen($cmd, "r")); 
} else {
    $cmd = "/usr/bin/php7.2-cli AsynchronDownload.php fileids=".$this->header->queryParams['ids'] . " uid=".$this->header->tokenData->uId . " groupId=".$this->header->tokenData->groupId . " timestamp=".$this->header->tokenData->timestamp . " state=".$this->header->tokenData->state. " token=".$this->header->tokenData->token;
    exec($cmd . " > /dev/null &");
}

Thats work fine. But is it possible to awnser to an Http Request, how is send to the first skript from a client in the second asynchron started skript? I found out the details about the Request are not available on the second skript.

If I try to set Headers for the Response with (for example) header('Content-type: x-zip') they are not set. headers_list() funktion returning NULL.

douzhi1813
douzhi1813 我知道PHP不是为我的问题而构建的,但我正在开发一个不支持node.js的1&1服务器,并且更改服务器对我来说不是一个可能的选择。我认为这是第二个问题,而不是真正通过Web服务器,而不是CLI。
接近 2 年之前 回复
duanboniao5903
duanboniao5903 如果你真的在寻找“异步”(本机),那么我就去找Node.js.PHP不是构建为异步和多线程的。
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐