PHPackages                             naroga/bernard-bundle - 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. naroga/bernard-bundle

ActiveSymfony-bundle[Queues &amp; Workers](/categories/queues)

naroga/bernard-bundle
=====================

Integrates Bernard into a Symfony2+ application.

v2.0.2(8y ago)046MITPHPPHP ^5.6|^7.0

Since Jan 24Pushed 6y agoCompare

[ Source](https://github.com/naroga/BernardBundle)[ Packagist](https://packagist.org/packages/naroga/bernard-bundle)[ Docs](http://bernard.readthedocs.org/)[ RSS](/packages/naroga-bernard-bundle/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (5)Versions (14)Used By (0)

BernardBundle
=============

[](#bernardbundle)

Integrates Bernard neatly with a Symfony application.

[![Build Status](https://camo.githubusercontent.com/3dd117565adfb1b52c3eec3fe4d98eaf634b4131bf72e969e3b9307f74129afd/68747470733a2f2f7472617669732d63692e6f72672f6265726e6172647068702f4265726e61726442756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/bernardphp/BernardBundle)

Getting Started
---------------

[](#getting-started)

Everything starts by installing the bundle. This is done through composer by adding the following lines to your `composer.json` file and running `composer update bernard/bernard-bundle`.

```
{
    "require" : {
        "bernard/bernard-bundle" : "~1.0"
    }
}
```

Next up is adding the bundle to your kernel and configuring it in `config.yml`.

```
// app/AppKernel.php
// .. previous class definition
public function registerBundles()
{
    // .. all the other bundles you have registered.
    $bundles[] = new Bernard\BernardBundle\BernardBernardBundle();
    // .. the rest of the method
}
```

```
# .. previous content of app/config/config.yml
bernard_bernard:
    driver: file # you can choose predis, phpredis, file, doctrine, sqs etc.
    serializer: simple # this is the default and it is optional. Other values are symfony or jms
```

Great! You are now ready to use this diddy. Go and read the rest of the documentation on Bernard at [bernardphp.com](http://bernardphp.com/).

### Running the Consumer

[](#running-the-consumer)

What good is a message queue if you don't know how to run the consumer? Luckily this bundle auto registers the commands with your application. So if you run `php app/console` you should see `bernard:consume` and `bernard:produce`. These work just as the documentation describes but if you are in doubt just add `--help` when running the command.

It is important to use `--no-debug` when running the consumer for longer periods of time. This is because Symfony by default in debug mode collects a lot of information and logging and if this is omitted you will run into memory problems sooner or later.

### Adding Receivers

[](#adding-receivers)

In order to know what messages needs to go where you have to register some receivers. This is done with a tag in your service definitions.

```
my_receiver:
    class: Acme\Receiver
    tags:
         - { name: bernard.receiver, message: SendNewsletter }
         - { name: bernard.receiver, message: ImportUsers }
```

As the example shows it is possible to register the same receiver for many different message types.

### Configuring Middlewares

[](#configuring-middlewares)

By default the three core middlewares are registered for the consumer and only needs to be turned on. This example shows enabling all of them. But remember theese are only enabled for the consumer.

```
bernard_bernard:
    middlewares:
        error_log: true
        logger: true # only for versions of symfony that implements PSR-3
        failures: true
```

This is all good, but what if you can code your own? Luckily this is taken care of with a tag for the container through a compiler pass. When you define your service just tag your middleware factory service with `bernard.middleware` and give it a `type` attribute with either `consumer` or `producer`.

```
my_middleware_factory:
    class: Acme\AwesomeMiddlewareFactory
    tags:
         - { name: bernard.middleware, type: consumer }
         - { name: bernard.middleware, type: producer }
```

As the example shows a middleware factory can be registered for both the consumer and producer.

Configuration Options
---------------------

[](#configuration-options)

There are different options that can be set that changes the behaviour for various drivers.

### Doctrine

[](#doctrine)

When using the doctrine driver it can be useful to use a seperate connection when using Bernard. In order to change it use the `connection` option. This also needs to be set if you default connection is called anything else than `default`.

```
doctrine:
    dbal:
        connections:
            bernard:
                host:     "%database_host%"
                charset:  UTF8

bernard_bernard:
    driver: doctrine
    options:
        connection: bernard # default is the default value
```

### FlatFile

[](#flatfile)

The file driver needs to know what directory it should use for storing messages and its queue metadata.

```
bernard_bernard:
    driver: file
    options:
        directory: %kernel.cache_dir%/bernard
```

The above example will dump your messages in the cache folder. In most cases you will want to change this to something because the cache folder is deleted every time the cache is cleared (obviously).

### PhpRedis

[](#phpredis)

PhpRedis depends on a service called `snc_redis.bernard` with a configured `Redis` instance. If you want to use a different name use the `phpredis_service` option:

```
bernard_bernard:
    driver: phpredis
    options:
        phpredis_service: my_redis_service
```

If you're using the [SncRedisBundle](https://github.com/snc/SncRedisBundle) you have to set logging to false for the bernhard client to ensure that is is a `Redis` instance and not wrapped.

### IronMQ

[](#ironmq)

When using the IronMQ driver you have to configure an `IronMQ` connection instance. You can configure it like the following:

```
services:
    ironmq_connection:
        class: IronMQ
        arguments:
            - { token: %ironmq_token%, project_id: %ironmq_project_id% }
        public: false

bernard_bernard:
    driver: ironmq
    options:
        ironmq_service: ironmq_connection
```

### Amazon SQS

[](#amazon-sqs)

To use Amazon SQS, configure your driver like this:

```
bernard_bernard:
    driver: sqs
    options:
        queue_map: # optional for aliasing queue urls, e.g.:
            send_newsletter: https://sqs.eu-west-1.amazonaws.com/...
        prefetch: 1 # optional, but beware the default is >1 and you may run into invisibility timeout problems with that
    sqs:
        region: "your aws region" # e.g. "eu-west-1"
        key: "your aws user's key"
        secret: "your aws user's secret"
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~199 days

Recently: every ~251 days

Total

12

Last Release

2304d ago

Major Versions

1.1.2 → 2.0.0-alpha12016-07-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/67a9373bd6218e10eaa1941dd01ec5ea1299d4534870e5c88722ec978f658f9d?d=identicon)[naroga](/maintainers/naroga)

---

Top Contributors

[![naroga](https://avatars.githubusercontent.com/u/3511149?v=4)](https://github.com/naroga "naroga (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/naroga-bernard-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/naroga-bernard-bundle/health.svg)](https://phpackages.com/packages/naroga-bernard-bundle)
```

###  Alternatives

[bernard/bernard-bundle

Integrates Bernard into a Symfony2 application.

96687.7k3](/packages/bernard-bernard-bundle)[mmoreram/gearman-bundle

Adds gearman support to your and Symfony4, Symfony5 project

237395.2k2](/packages/mmoreram-gearman-bundle)[webfactory/icu-translation-bundle

Enables ICU message formatting for translations in Symfony applications.

2761.8k](/packages/webfactory-icu-translation-bundle)[ecotone/symfony-bundle

Extends Ecotone with Symfony integration

11229.0k1](/packages/ecotone-symfony-bundle)[idct/symfony-nats-messenger

Symfony NATS (JetStream) Messenger Bridge

181.2k](/packages/idct-symfony-nats-messenger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
