This package is abandoned and no longer maintained. The author suggests using the symfony/messenger package instead.

Adds worker functionality to a Symfony2 project, using Beanstalkd as the message queue

Installs: 57 109

Dependents: 1

Suggesters: 1

Security: 0

Stars: 13

Watchers: 7

Forks: 7

Open Issues: 4


2.0.1 2019-11-13 10:19 UTC

This package is auto-updated.

Last update: 2020-02-13 08:48:31 UTC


This bundle is no longer maintained. It will still work with Symfony versions ^2.8|^3.0|^4.0 and is archived here to not break existing applications using it. However it will not get maintenance updates or even security fixes.

If you need queue/worker functionality in your project, there are far better solutions right now to look at:

Previous readme below 👇

Worker bundle

Latest Version on Packagist Software License Build Status Coverage Status Quality Score

A Symfony bundle that adds worker functionality to your project, using Beanstalkd as the message queue.


For this process, we assume you have a Beanstalk server up and running.

Install via Composer:

$ composer require treehouselabs/worker-bundle

Enable the bundle:

# app/AppKernel.php
class AppKernel extends Kernel
    public function registerBundles()
        $bundles = [
            // ...

            new TreeHouse\WorkerBundle\TreeHouseWorkerBundle(),

        // ...

    // ...


Define a queue and you're good to go:

# app/config/config.yml

    server: localhost

The bundle also supports the PheanstalkBundle, if you're using that:

# app/config/config.yml

  pheanstalk: leezy.pheanstalk

Basic Usage

The bundle creates a QueueManager service, which you can use to manage jobs. The manager has services registered to execute specific tasks, called executors. An executor receives a job from the QueueManager and processes it.

Defining executors

First you need to register an executor, and tag it as such:

# src/AppBundle/Executor/HelloWorldExecutor.php

use TreeHouse\WorkerBundle\Executor\AbstractExecutor;

class HelloWorldExecutor extends AbstractExecutor
    public function getName()
        return '';

    public function configurePayload(OptionsResolver $resolver)

    public function execute(array $payload)
        $name = array_shift($payload);

        # process stuff here, in this example we just print something
        echo 'Hello, ' . $name;

        return true;
# app/config/services.yml
  class: AppBundle/Executor/HelloWorldExecutor
    - { name: tree_house.worker.executor }

Scheduling jobs

Now you can add jobs, either via code or using the worker:schedule command:

In your application's code:

$queueManager = $container->get('tree_house.worker.queue_manager');
$queueManager->add('', ['Peter']);

Using the command:

php app/console worker:schedule Peter

Working jobs

A worker can now receive and process these jobs via the console:

php app/console worker:run

# prints:
# Working with payload ["Peter"]
# Hello, Peter
# Completed job in 1ms with result: true

You can run workers by adding them to your crontab, creating a Supervisor program for it, or whatever your preferred method is.


  1. Message queues & workers
  2. The QueueManager
  3. Executors
  4. Working jobs


If you discover any security related issues, please email instead of using the issue tracker.


The MIT License (MIT). Please see License File for more information.