Skip to content

Latest commit

 

History

History
90 lines (70 loc) · 2.06 KB

README.md

File metadata and controls

90 lines (70 loc) · 2.06 KB

symfony-pubnub ABANDONNED DO NOT USE THAT

Implement Pubnub into your Symfony application.

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require txtony/symfony-pubnub

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new TxTony\SymfonyPubnub\TxTonySymfonyPubnubBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Configuration

All configuration options on the Pubnub\Pubnub class can be configured. Only publish_key and subscribe_key are required. Default reference is below.

tx_tony_symfony_pubnub:
    publish_key: <your_pub_key> # Required
    subscribe_key: <your_sub_key> # Required
    secret_key: false
    cipher_key: false
    ssl: true
    origin: false
    pem_path: "%kernel.root_dir%/../vendor/pubnub/pubnub/"
    uuid: symfony
    proxy: false
    auth_key: false
    verify_peer: true

Step 4: Usage

Get the pubnub client from the container.

$pubnub = $this->get('txtony.pubnub.client.pubnub');

In your code this is an exemple to publish message in 'myChannel'

// return a timetoken like this "timetoken": 123456789123456789
return $pubnub->getPubnub()->publish()
    ->channel("myChannel")
    ->message("Hello world")
    ->usePost(true)
    ->sync();

The $pubnub object is an instance of Pubnub\Pubnub. Usage documentation can be found in the Pubnub repository.