Skip to content
Minimalistic PHP client for beanstalkd without any dependencies
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Removing deprecated errors, choose and listTubeChosen methods. Jan 13, 2015
tests 2015 Jan 13, 2015
.gitignore Reorganize tests. Jan 13, 2015
.travis.yml Adding travis configuration. Jan 13, 2015
LICENSE 2015 Jan 13, 2015
README 2015 Jan 13, 2015


---- Minimalistic PHP client for beanstalkd.

This library allows you to interface with the beanstalkd[1] work queue and is
built with a minimal featureset still supporting the complete protocol. The
main (and currently only) class can be found at `src/Client.php`.

The class was formerly part of the queue plugin for CakePHP[2]. It has been
extracted for higher reusability in other places and frameworks.

Cute[3] is such a project. It uses this library to provide convenient
access and tooling around the work queue for PHP.


Copyright & License
Beanstalk, a beanstalk PHP client library for the beanstalkd work queue is
Copyright (c) 2009-2015 David Persson if not otherwise stated. The code
is distributed under the terms of the MIT License. For the full license
text see the LICENSE file.

Versions & Requirements
1.0.0, PHP >=5.2.1
1.1.0, PHP >=5.2.1
2.0.0, PHP >=5.4.1

Note: In PHP Versions 5.3.9, 5.3.10 and 5.4.0 the `stream_get_line()`
      function exhibits buggy behavior (PHP bug #60817), thus
      these versions cannot be used with this library.

The preferred installation method is via composer. You can add the library
as a dependency via:

$ composer require davidpersson/beanstalk


use Beanstalk\Client;

// A sample producer.
$beanstalk = new Client(); // For connection options see the
                           // class documentation.

$beanstalk->useTube('flux'); // Begin to use tube `'flux'`.
    23, // Give the job a priority of 23.
    0,  // Do not wait to put job into the ready queue.
    60, // Give the job 1 minute to run.
    '/path/to/cat-image.png' // The job's body.

// A sample consumer.
$beanstalk = new Client();


while (true) {
    $job = $beanstalk->reserve(); // Block until job is available.
    // Now $job is an array which contains its ID and body:
    // ['id' => 123, 'body' => '/path/to/cat-image.png']

    // Processing of the job...
    $result = touch($job['body']);

    if ($result) {
    } else {
// When exiting i.e. on critical error conditions
// you may also want to disconnect the consumer.
// $beanstalk->disconnect();


Running the Tests
The integration tests contained in this library require a running beanstalkd
instance. You'll need to start a dedicated instance on port 11301 as follows.

beanstalkd -VV -l -p 11301

Tests for this library are PHPUnit based. To run the tests you'll need
to have PHPUnit installed[1]. Following commands will run all the tests.

cd /path/to/beanstalk
composer install

vendor/bin/phpunit tests

You can’t perform that action at this time.