PHP code example of mhndev / pusher

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

    

mhndev / pusher example snippets



use mhndev\pusher\PusherFactory;

ient();

$message = new \mhndev\pusher\Message([
    'name'   => 'majid',
    'family' => 'abdolhosseini',
    'age'    => 25
]);




//send message using pusher.com service
$pusherDotComService = PusherFactory::createPusher(
    PusherFactory::PUSHER_PUSHERDOTCOM,
    ['app_key', 'app_secret', 'app_id', []]
);
$pusherDotComService->push($message, 'device1');




//send message using pubnub.com service
$pubnub = PusherFactory::createPusher(
    PusherFactory::PUSHER_PUBNUB, 
    ['public_key', 'subscribe_key', 'secret_key']
);
$pubnub->push($message, 'device1');



//send message using FCM service
$fcm = PusherFactory::createPusher(
    PusherFactory::PUSHER_FCM, 
    ['api_key', $httpClient]
);
$fcm->push($message, 'device1');



//send message using GCM service
$gcm = PusherFactory::createPusher(
    PusherFactory::PUSHER_GCM,
    ['api_key']
);
$gcm->push($message, 'device1');



//send message using nginx push stream module
$nginx = PusherFactory::createPusher(
    PusherFactory::PUSHER_NGINXMODULE,
    [$httpClient, 'http://example.com:8000']
);
$nginx->push($message, 'device1');