L'exécution asynchrone en fonction en php

est-il possible de créer une certaine classe php qui permet d'exécuter des fonctions de façon asynchrone? Voici ce que j'ai fait jusqu'à présent:

class Worker extends Thread
{
    protected  $asyncFun;
    protected $paramsArray;

    public function run() {
        $asyncFun(/*parameters go here*/)
    }

    public function setAsyncFunction($func, $paramsArr)
    {
        $this->asyncFun = $func;
        $this->paramsArray = $paramsArr;
    }
}

Voici comment je veux l'appeler:

$worker = new Worker();
$worker->setAsyncFunction(foo, ["a", "b"]);
$worker::start();
je voudrais lancer un nouveau script php avec exec
pouvez-vous mettre un peu de code?
exec('php script.php')
mais il n'est pas dynamique de cette façon.
À partir du manuel PHP: Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends. - Est votre définition de l'asynchrone?

OriginalL'auteur vlio20 | 2014-12-02