PHPackages                             raphaeu/async - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. raphaeu/async

ActiveProject

raphaeu/async
=============

Php assyncrono

3.0.0.5(5y ago)059MITPHPPHP &gt;=5.6

Since May 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/raphaeu/async)[ Packagist](https://packagist.org/packages/raphaeu/async)[ RSS](/packages/raphaeu-async/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (8)Used By (0)

async
=====

[](#async)

[![Latest Stable Version](https://camo.githubusercontent.com/55b6b17af7bc10c4d4293738789c75d24110a0152e5f54a987772a1a93771995/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726170686165752f6173796e63)](https://packagist.org/packages/raphaeu/async)[![Total Downloads](https://camo.githubusercontent.com/17ebc97953ce7d46c90323dac9a25050cf5ccb91b6c8483b9507c22604e6a1cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726170686165752f6173796e63)](https://packagist.org/packages/raphaeu/async)[![Author](https://camo.githubusercontent.com/fa8ce040289c5f78a953f1829436dd531d11c273f13be53dcf0e3f2fda0d6349/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d726170686165752d626c75652e737667)](https://www.linkedin.com/in/rafael-aguiar-74824922/)[![License](https://camo.githubusercontent.com/8a2fd669099deb29a50bbed8fddb0c52d16d2072fa6eeaf9b36e463ec5a206a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f726170686165752f6173796e63)](https://packagist.org/packages/raphaeu/async)

Fazer resquisições multitask assíncronas com PHP de forma fácil e eficiente.

Requisitos
----------

[](#requisitos)

- [PHP](https://php.net) &gt;= 5.6

Instalando com composer
-----------------------

[](#instalando-com-composer)

```
composer require raphaeu/async
```

Usando
------

[](#usando)

```
// Import
use async\Task;
use async\Async;

// Inicialize async class
$async = new Async();

// Create tasks
$task1 = new Task("php /tmp/randTimer.php");
$task2 = new Task("php /tmp/randTimer.php");
$task3 = new Task("php /tmp/randTimer.php");

// Vinculando testes
$async->addTask($task1);
$async->addTask($task2);
$async->addTask($task3);

// Rodando tarefas assíncronas
while ($totalOk = $async->hasDo())
{
    echo "Rodando: ".((count($async->getTasks()) - $totalOk) + 1)."/". count($async->getTasks()) ."\r";
    usleep(250);
}

// Pegando resultados das tarefas
foreach ($async->getTasks() as $task)
{
    echo PHP_EOL. $task->getResult();
}
```

#### Arquivo do teste assíncrono **randTimer.php**

[](#arquivo-do-teste-assíncrono-randtimerphp)

```
