PHP code example of oktopost / tattler-php

1. Go to this page and download the library: Download oktopost/tattler-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oktopost / tattler-php example snippets


$config = new TattlerConfig();
$tattlerConfig->fromArray([
        'WsAddress'         => 'TATTLER_WEBSOCKET_ADDRESS',
        'ApiAddress'        => 'TATTLER_API_ADDRESS',
        'Namespace'         => 'YOUR APPLICATION_NAME',
        'Secret'            => 'TATTLER_SECRET',
        'TokenTTL'          => 'USER_TOKEN_TTL',
        'DBConnector'       => new RedisConnector(),
        'NetworkConnector'  => new CurlConnector()
]);

/** @var ITattlerModule::class $tattler */
$tattler = Tattler::getInstance($tattlerConfig);

/** var ITattlerMessage::class $message */
$message = new TattlerMessage();
$message->setHandler('myMessage')->setNamespace('globalNamespace')->setPayload(['message' => 'Hello world']]);

$tattler->message($message)->broadcast()->say();
bash
$ composer