PHP code example of pikoman / compat-php

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

    

pikoman / compat-php example snippets


use Pikoman\Compat\Pusher;   // was: use Pusher\Pusher;

$pusher = new Pusher(
    getenv('PIKOMAN_APP'),          // was: the key
    getenv('PIKOMAN_API_KEY'),      // was: the secret
    getenv('PIKOMAN_PRIVATE_KEY'),  // was: the app id
);

$pusher->trigger('orders', 'order-shipped', ['id' => 1042]);
$pusher->trigger(['orders', 'admin'], 'order-shipped', $data, ['socket_id' => $_POST['socket_id']]);
$pusher->triggerBatch([
    ['channel' => 'orders', 'name' => 'order-shipped', 'data' => ['id' => 1042]],
    ['channel' => 'stock', 'name' => 'changed', 'data' => ['sku' => 'A7']],
]);

// The auth endpoint
echo $pusher->authorizeChannel($_POST['channel_name'], $_POST['socket_id']);
echo $pusher->authorizePresenceChannel($_POST['channel_name'], $_POST['socket_id'], $userId, ['name' => $name]);
bash
composer