Created: 2008-10-14 06:30
Updated: 2019-03-01 15:30
License: mit


Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage Build Status

Pheanstalk is a pure PHP 7.1+ client for the beanstalkd workqueue. It has been actively developed, and used in production by many, since late 2008.

Created by Paul Annesley, Pheanstalk is rigorously unit tested and written using encapsulated, maintainable object oriented design. Community feedback, bug reports and patches has led to a stable 1.0 release in 2010, a 2.0 release in 2013, and a 3.0 release in 2014.

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

In 2018 Sam Mousa took on the responsibility of maintaining Pheanstalk.

Pheanstalk 4.0 drops support for older PHP versions. It contains the following changes (among other things):

  • Strict PHP type hinting
  • Value objects for Job IDs
  • Functions without side effects
  • Dropped support for persistent connections
  • Add support for multiple socket implementations (streams extension, socket extension, fsockopen)

beanstalkd up to the latest version 1.10 is supported. All commands and responses specified in the protocol documentation for beanstalkd 1.3 are implemented.

Installation with Composer

Install pheanstalk as a dependency with composer:

composer require pda/pheanstalk

Usage Example


// Hopefully you're using Composer autoloading.

use Pheanstalk\Pheanstalk;
// Create using autodetection of socket implementation
$pheanstalk = Pheanstalk::create('');

// ----------------------------------------
// producer (queues jobs)

  ->put("job payload goes here\n");

// ----------------------------------------
// worker (performs jobs)

$job = $pheanstalk

echo $job->getData();


Running the tests

If you have docker-compose installed running tests is as simple as:

> composer test

If you don't then you manually need to set up a beanstalk server and run:

> vendor/bin/phpunit



© Paul Annesley

Released under the The MIT License

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more