danwdart / php-async

Async methods for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP-Async

Works like Javascript's setTimeout/setInterval.

Async::async() also runs the next piece of code independently (much like requestAnimationFrame or setImmediate/nextTick).

Installation

composer require jolharg/async

Usage

<?php
namespace Whatever;

use Jolharg/Async;

class Whatever
{
    public function whatever()
    {
        Async::async(function() { echo 'hi'; })
    }

    public function somethingElse()
    {
        Async::setTimeout(function() { echo 'hi'}, 1000);
        Async::setInterval(function() { echo 'hi'}, 2000);
    }
}

About

Async methods for PHP


Languages

Language:Nix 90.4%Language:PHP 9.6%