PHPackages                             heydon/phpeanstalk-worker - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. heydon/phpeanstalk-worker

ActiveLibrary[Queues &amp; Workers](/categories/queues)

heydon/phpeanstalk-worker
=========================

Phpworker for the Phpeanstalk library

43603[1 issues](https://github.com/gheydon/pheanstalk-worker/issues)PHP

Since Mar 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/gheydon/pheanstalk-worker)[ Packagist](https://packagist.org/packages/heydon/phpeanstalk-worker)[ RSS](/packages/heydon-phpeanstalk-worker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Pheanstalk
==========

[](#pheanstalk)

[![Build Status](https://camo.githubusercontent.com/c2cd605e966048a2f007e0cbb0af7601f7c2f799d673d53b6f664c16c676979a/68747470733a2f2f7472617669732d63692e6f72672f67686579646f6e2f706865616e7374616c6b2d776f726b65722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/gheydon/pheanstalk-worker)

Pheanstalk is a pure PHP 5.4+ client for the [beanstalkd workqueue](http://xph.us/software/beanstalkd/). It has been actively developed, and used in production by many, since late 2008.

Created by [Gordon Heydon](http://heydon.com.au/), Pheanstalk Worker has ben created as a best of bread worker. Started in Jan 2015 as stable implementation of a worker for [Pheanstalk](https://github.com/pda/pheanstalk) to either to be used as a proper example of how a worker should be created or as an implementation that can be used in a production system.

Pheanstalk Worker 1.0 introduces PHP namespaces, PSR-1 and PSR-2 coding standards, and PSR-4 autoloader standard.

Installation with Composer
--------------------------

[](#installation-with-composer)

Install pheanstalk-worker as a dependency with composer:

```
composer require heydon/pheanstalk-worker
```

Creating a worker
-----------------

[](#creating-a-worker)

A worker is a process which when runs takes the next job off a set of queues which are being watched and then executes the job with the defined tasks.

The worker process runs the following steps:

1. Watch all registered tubes
2. Reserve the next job
3. Once job is reserved, invoke the registered handler based on the tube name
4. If no exceptions occur, delete the job (success)
5. If 'retry\_on' exceptions occur, call 'release' (retry)
6. If other exception occurs, call 'bury' (error)
7. Repeat steps 2-6

To create a worker use the following example.

```
