PHP code example of larva / pusher-sdk

1. Go to this page and download the library: Download larva/pusher-sdk 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/ */

    

larva / pusher-sdk example snippets


$forge = new Larva\Pusher\Forge('http://ws.domain.com', TOKEN_HERE);

$res = $forge->publish('6557749ee6d95#32131','event', ['name'=>'张三']);

$res = $forge->trigger('room1','event', ['name'=>'张三']);

//或者

$channel = $forge->channel('room1');
$channel->trigger('event', ['name'=>'张三']);

$channel = $forge->channel('room1');
$channel->online_users;