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
<?php // Hopefully you're using Composer autoloading. use Pheanstalk\Pheanstalk; // Create using autodetection of socket implementation $pheanstalk = Pheanstalk::create('127.0.0.1'); // ---------------------------------------- // producer (queues jobs) $pheanstalk ->useTube('testtube') ->put("job payload goes here\n"); // ---------------------------------------- // worker (performs jobs) $job = $pheanstalk ->watch('testtube') ->ignore('default') ->reserve(); echo $job->getData(); $pheanstalk->delete($job);
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:
- Paul Annesley
- Lachlan Donald
- Joakim Bick
- Peter McArthur
- Geoff Catlin
- Steven Lewis
- Lars Yencken
- Josh Butts
- Henry Smith
- Javier Spagnoletti
- Graham Campbell
- Thomas Tourlourat
- Matthieu Napoli
- James Hamilton
- Hannes Van De Vreken
- Yaniv Davidovitch
- Sam Mousa
- .. more? Let me know if you're missing.
© Paul Annesley
Released under the The MIT License