PHPackages                             phlask/phlask - 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. phlask/phlask

ActiveLibrary

phlask/phlask
=============

PHP parallel task management.

0.2.1-alpha(12y ago)54.9k3[1 issues](https://github.com/nicktacular/phlask/issues)MITPHPPHP &gt;=5.3.27

Since Feb 19Pushed 7y ago4 watchersCompare

[ Source](https://github.com/nicktacular/phlask)[ Packagist](https://packagist.org/packages/phlask/phlask)[ Docs](http://github.com/nicktacular/phlask)[ RSS](/packages/phlask-phlask/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (4)Versions (6)Used By (0)

phlask
======

[](#phlask)

A task runner that can be run in a distributed environment, consuming tasks off a queue and running tasks in parallel as separate processes. None of the processes will affect each other, thereby allowing any task to be run in virtually any language with the ability to continue running tasks even when some (or all tasks) fail.

Currently queues are available for [MongoDB](http://mongodb.org) (currently building for [RabbitMQ](http://rabbitmq.com)). Other queue interfaces are planned for Redis, Amazon SQS, and MySQL.

### Build status

[](#build-status)

Master: [![Build Status](https://camo.githubusercontent.com/80dada35decdfce6367d95d391985275d8ab03cf230ed26551ae4fc530bbad60/68747470733a2f2f7472617669732d63692e6f72672f6e69636b746163756c61722f70686c61736b2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/nicktacular/phlask)Develop: [![Build Status](https://camo.githubusercontent.com/cbd6c69ae6131593a0537a9c0fb40a4c9c828642a6c17162611038ee6589e0b1/68747470733a2f2f7472617669732d63692e6f72672f6e69636b746163756c61722f70686c61736b2e706e673f6272616e63683d646576656c6f70)](http://travis-ci.org/nicktacular/phlask)

How to use this?
----------------

[](#how-to-use-this)

```
$runner = \phlask\Runner::factory(array(
    'tasks'             => new \phlask\TaskQueue\MongoQueue($host, $db, $collection),
    'wait'              => 20,
    'daemon'            => false,
    'max_processes'     => 10
));

$runner->run();
```

In the simplest case, a `\phlask\Runner` instance is created that will read tasks from a MongoDB queue and run them until all the tasks have run and exit. Alternatively, the application can be run as a daemon in the background by setting `daemon` config as `true` in the factory. The `Runner` is made to run in the background in this manner, consuming tasks as soon as they are made available on the queue. Keep in mind that the `daemon` flag is meant to indicate that this process could run in the background (i.e. without any timeouts by PHP) but the actual task of writing a daemon is up to the developer using this library. For more information, read about [creating daemons](daemon.md).

Creating jobs
-------------

[](#creating-jobs)

Any possible job can be created as long as the job follows the `\phlask\TaskSpecInterface` which defines some methods that are necessary to determine what it means to "run a job". This concept of a job is deliberately abstract to allow the user of this library to write their own task specifications that can be run as soon as they're placed on a stack by any host that is aware of the queue.

A simple example of what a task is can be found in `\phlask\TaskSpec\PhpRunnable` which can be created in this way. Suppose you want to run a PHP script located in this file: `/home/me/file.php`. You could set up your task like so:

```
$task = \phlask\TaskSpec\PhpRunnable::factory(array(
    'file' => '/home/me/file.php',
    'php' => '/usr/bin/php'
));
```

It's that simple. You could also pass additional parameters by specifying `args` as a config.

Now, you need to add to some queue. Suppose you're using a MongoDB queue. It's fairly straightforward. Simply push the task you just created on to the queue:

```
$queue = new \phlask\TaskQueue\MongoQueue('mongodb://127.0.0.1', 'db', 'queue');
$queue->pushTask($task);
```

That's all you need to do for adding a job to a queue.

Running jobs
------------

[](#running-jobs)

Running jobs requires starting the `Runner` in some way, either to run a finite number of tasks or to run as a daemon in the background, listening to the queue for new tasks to run. There are many different ways of creating a daemon script. You can read more about [creating daemons](daemon.md).

In order to create a functioning `Runner`, we need to know about the task queue and some basic settings to start.

```
$runner = \phlask\Runner::factory(array(
    'tasks'             => new \phlask\TaskQueue\MongoQueue('mongodb://127.0.0.1', 'myDb', 'queue'),
    'wait'              => 20,//milliseconds for waiting for new tasks
    'daemon'            => true,//run in the background
    'max_processes'     => 10//maximum parallel processes
));

$runner->run();
```

The `tasks` config points to an instance of the queue. It can be any queue that implements the `phlask\TaskQueueInterface`. In this example we've chosen MongoDB on the localhost. The `wait` config indicates how many milliseconds we should wait for when there are no tasks on the queue. It is recommended to set `max_processes` to prevent too many processes from running in parallel if your task queue fills up with many jobs. The `daemon` flag will let the `Runner` run in daemon mode.

Contributing
------------

[](#contributing)

If you'd like to contribute to this project, please issue a pull request. I'd love to see more queue implementations or `TaskSpecInterface` implementations added.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

3

Last Release

4431d ago

PHP version history (2 changes)v0.1.0-alphaPHP &gt;=5.4.0

v0.1.2-alphaPHP &gt;=5.3.27

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d6962dea811c2bc8482dd78bad8773492cb5fc07ba0ecc8aee5e534c257c7ec?d=identicon)[nicktacular](/maintainers/nicktacular)

---

Top Contributors

[![nicktacular](https://avatars.githubusercontent.com/u/810546?v=4)](https://github.com/nicktacular "nicktacular (67 commits)")[![fbouliane](https://avatars.githubusercontent.com/u/1572444?v=4)](https://github.com/fbouliane "fbouliane (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/phlask-phlask/health.svg)

```
[![Health](https://phpackages.com/badges/phlask-phlask/health.svg)](https://phpackages.com/packages/phlask-phlask)
```

###  Alternatives

[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[drevops/git-artifact

Package artifact from your codebase in CI and push it to a separate git repo.

2133.2k](/packages/drevops-git-artifact)[doppar/framework

The Doppar Framework

366.7k8](/packages/doppar-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
