A Pusher bundle for Symfony2

Installs: 30 956

Dependents: 1

Stars: 38

Watchers: 3

Forks: 20

Open Issues: 2

Type: symfony-bundle

v1.2.6 2015-06-25 14:17 UTC


Build Status SensioLabsInsight Latest Stable Version Latest Unstable Version Bitdeli Badge

This bundle let you use Pusher simply.

Pusher (Documentation) is a simple hosted API for adding realtime bi-directional functionality via WebSockets to web and mobile apps, or any other Internet connected device.

This bundle is under the MIT license.


Use the composer to install this bundle.

$ composer require laupifrpar/pusher-bundle

Then update your AppKernel.php file, and register the new bundle:


// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Lopi\Bundle\PusherBundle\LopiPusherBundle(),
    // ...


If you have not a Pusher account, thank you to sign up and make a note of your API key before continuing


This is the default configuration in yml:

# app/config/config.yml
    app_id: <your_app_id>
    key: <your_key>
    secret: <your_secret>

    # Default configuration
    debug: false # true if you want use the debug of all requests
    port: 80
    timeout: 30

    # Optional configuration
    auth_service_id: <the_auth_service_id> # optional if you want to use private or presence channels

By default, calls will be made over a non-encrypted connection. To change this to make calls over HTTPS:

# app/config/config.yml
    port: 443

Private and Presence channel authentication (optional)

If you'd like to use private or presence, you need to add an authorization service.

First, create an authorization service that implements Lopi\Bundle\PusherBundle\Authenticator\ChannelAuthenticatorInterface

// My/Bundle/AcmeBundle/Pusher/ChannelAuthenticator

namespace My\Bundle\AcmeBundle\Pusher

use Lopi\Bundle\PusherBundle\Authenticator\ChannelAuthenticatorInterface;

class ChannelAuthenticator implements ChannelAuthenticatorInterface
    public function authenticate($socketId, $channelName)
        // logic here

        return true;

Then include it's service id in the lopi_pusher auth_service_id configuration parameter.

Additionally, enable the route by adding the following to your app\config\routing.yml configuration:

# app\config\routing.yml
    resource: "@LopiPusherBundle/Resources/config/routing.xml"
    prefix:   /pusher

In some symfony configurations, you may need to manually specify the channel_auth_endpoint: (not required in most setups)

<script type="text/javascript">
    Pusher.channel_auth_endpoint = "{{ path('lopi_pusher_bundle_auth') }}";

Use LopiPusherBundle

Get the pusher service

$pusher = $this->container->get('lopi_pusher.pusher');

See the pusher's documentation to use the pusher service

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.