PHPackages                             yokai/messenger-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. yokai/messenger-bundle

Abandoned → [symfony/notifier](/?search=symfony%2Fnotifier)ArchivedLibrary

yokai/messenger-bundle
======================

Simplify message sending processes in a Symfony project

v1.5(7y ago)221.1k4[6 issues](https://github.com/yokai-php/messenger-bundle/issues)MITPHPPHP &gt;=5.6

Since Aug 3Pushed 6y ago6 watchersCompare

[ Source](https://github.com/yokai-php/messenger-bundle)[ Packagist](https://packagist.org/packages/yokai/messenger-bundle)[ RSS](/packages/yokai-messenger-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (10)Versions (22)Used By (0)

YokaiMessengerBundle
====================

[](#yokaimessengerbundle)

> ⚠️ This package is abandoned and no longer maintained. The author suggests using the [symfony/notifier](https://github.com/symfony/notifier) package instead.

[![Latest Stable Version](https://camo.githubusercontent.com/e2e4eca3259553aad99aceb9341113259904a97df31b0560e48641d771b38c56/68747470733a2f2f706f7365722e707567782e6f72672f796f6b61692f6d657373656e6765722d62756e646c652f762f737461626c65)](https://packagist.org/packages/yokai/messenger-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/46492c6bacf817a7f5f093793dbfa92583ee5a564b47a07683497a5ef7d09382/68747470733a2f2f706f7365722e707567782e6f72672f796f6b61692f6d657373656e6765722d62756e646c652f762f756e737461626c65)](https://packagist.org/packages/yokai/messenger-bundle)[![Total Downloads](https://camo.githubusercontent.com/6f4a69ce8b69e634c5c98a41fb328b519465bf1cb874a98154757d02333480a9/68747470733a2f2f706f7365722e707567782e6f72672f796f6b61692f6d657373656e6765722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/yokai/messenger-bundle)[![License](https://camo.githubusercontent.com/962579fd203c1a2c69a92fbd01ed0bfd28d63c081ef0c5a31b166f227d6fe50e/68747470733a2f2f706f7365722e707567782e6f72672f796f6b61692f6d657373656e6765722d62756e646c652f6c6963656e7365)](https://packagist.org/packages/yokai/messenger-bundle)

[![Build Status](https://camo.githubusercontent.com/166bda39a8b75b5946fbe83b373730e1054f6e35095dd6d3320f72889655d014/68747470733a2f2f6170692e7472617669732d63692e6f72672f796f6b61692d7068702f6d657373656e6765722d62756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/yokai-php/messenger-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5808f87a8d61ccae790fcc8311bd2ee54375d3b70e0bb3b58caf00c56d7c22ba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796f6b61692d7068702f6d657373656e6765722d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yokai-php/messenger-bundle/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7799f6ac20417eda32cea5781d73b16fc140a6c8343b8f942797b1c87caa81e4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796f6b61692d7068702f6d657373656e6765722d62756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yokai-php/messenger-bundle/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/7f35b90d954adbbca71555698be7a0f8e99c6a4b1f4f779f0bad522d13e29da9/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37383432303665642d366261312d343533652d393134312d3165663363376636613062322f6d696e692e706e67)](https://insight.sensiolabs.com/projects/784206ed-6ba1-453e-9141-1ef3c7f6a0b2)

Simplify message sending processes in a Symfony2 project.

Imagine that your application sends emails, triggers UI notifications, sends SMS. You are using several libraries to do it. And if you did not factorize your code, you will have bunch of copy paste in every place you are sending something.

Worst, if you was expecting to send an email some day, you may send also an SMS tomorrow. If that happen, you will need to rewrite your code...

This bundle is trying to help with all these problems, providing a simple way to configure a distribute these messages.

Principles
----------

[](#principles)

### Message

[](#message)

A `message` represent the fact that your application is sending something.

Creating a `message` is as easy as creating a service of class `Yokai\MessengerBundle\Message`with at least 1 `yokai_messenger.message` tag, for each tag you specify the `channel` on which the message should be distributed.

You can also register it using this bundle [configuration](Resources/docs/configuration.md#messages).

### Recipient

[](#recipient)

A `recipient` represent the information about the target of your message.

Every `channel` is free to support only certain types of recipient (mostly by checking interfaces).

### Channel

[](#channel)

A `channel` represent a way to distribute `messages`.

This bundle come with some built-in `channels`:

- `Yokai\MessengerBundle\Channel\SwiftmailerChannel` : sending an email with [Swift Mailer](https://github.com/swiftmailer/swiftmailer). Read the channel [documentation](Resources/docs/channels/swiftmailer.md)
- `Yokai\MessengerBundle\Channel\DoctrineChannel` : recording a database entry with [Doctrine ORM](https://github.com/doctrine/doctrine2). Read the channel [documentation](Resources/docs/channels/doctrine.md)
- `Yokai\MessengerBundle\Channel\MobileChannel` : pushing a mobile notification with [NotificationPusher](https://github.com/Ph3nol/NotificationPusher). Read the channel [documentation](Resources/docs/channels/mobile.md)

Creating a `channel` is as easy as creating a service that implements `Yokai\MessengerBundle\Channel\ChannelInterface`with the `yokai_messenger.channel` tag.

A `channel` will be asked to handle a `delivery` whenever a message is about to be sent.

### Delivery

[](#delivery)

A `delivery` (`Yokai\MessengerBundle\Delivery`) represent the `message` about to be sent to a `recipient` for a `channel`. It is mainly matter of storing all the data in the same place.

Creating a `delivery` is an internal process, that must be done by the `sender`.

Sender
------

[](#sender)

The `sender` is your entry point for sending messages.

It centralize the configuration of which `messages` to send over which `channels`.

Installation
------------

[](#installation)

### Add the bundle as dependency with Composer

[](#add-the-bundle-as-dependency-with-composer)

```
$ php composer.phar require yokai/messenger-bundle
```

### Enable the bundle in the kernel

[](#enable-the-bundle-in-the-kernel)

```
