Simple worker and pool library.

dev-master 2016-05-30 16:20 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:34:04 UTC


Build Status Test Coverage Scrutinizer Code Quality Code Climate

Latest Stable Version Latest Unstable Version License Total Downloads


To install the Simple Worker library in your project using Composer, first add the following to your composer.json config file.

    "require": {
        "gielfeldt/simple-worker": "^0.1"

Then run Composer's install or update commands to complete installation. Please visit the Composer homepage for more information about how to use Composer.

Simple Worker

This class allows you to queue operations in a pool and let them commence when ready.


  1. De-coupling of the handling of guzzle asynchronous requests.

Using the Simple Worker library


namespace Gielfeldt\SimpleWorker\Example;

require 'vendor/autoload.php';

use Gielfeldt\SimpleWorker\Pool;
use Gielfeldt\SimpleWorker\Test\SimpleTestWorker;

$pool = new Pool(['concurrency' => 1]);

$time = microtime(true);
$workers = [];
for ($i = 0; $i < 10; $i++) {
    $workers[] = new SimpleTestWorker(uniqid(), 0.5);

print "Adding worker\n";
$pool->addWorkers($workers, function ($worker) use ($time) {
    $elapsed = microtime(true) - $time;
    print "\n$worker->key is ready! Elapsed time: $elapsed\n";

print "Processing workers\n";
    'progress_callback' => function ($pool) {
        print ".";
    'finish_callback' => function ($pool) {
        print "\n";

For more examples see the examples/ folder.


  • Queue operations in a pool.


  1. Lots probably.