PHP code example of obaid / pushmanlib

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

    

obaid / pushmanlib example snippets


composer 

use Pushman\PHPLib\Pushman;
$pushman = new Pushman('private-key-goes-here');

$response = $pushman->push('kittens_are_cute', 'public', ['foo' => 'asdasdasdasd']);

use Pushman\PHPLib\Pushman;
$pushman = new Pushman('private-key-goes-here');

$response = $pushman->push('kittens_are_cute', ['public', 'auth'], ['foo' => 'asdasdasdasd']);

use Pushman\PHPLib\Pushman;
$pushman = new Pushman('private-key-goes-here, ['url' => 'http://pushman.yoursite.com']);

$response = $pushman->push('kittens_are_cute', 'public', ['foo' => 'asdasdasdasd']);

'pushman' => [
    'driver'  => 'pushman',
    'private' => env('PUSHMAN_PRIVATE'),
    'url'     => env('PUSHMAN_URL'),
],

$user = new User([
	'name' => 'James Duffleman',
	'email' => '[email protected]',
	'password' => bcrypt('aPassword')
]);

event(new UserCreated($user));

use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UserCreated extends Event implements ShouldBroadcast {

    public $user;

    public function __construct($user)
    {
        $this->user = $user;
    }
    
    public function broadcastOn()
    {
        return ['public'];
    }
}

use Pushman\PHPLib\Pushman;
$pushman = new Pushman('private-key-goes-here');

$response = $pushman->token('public');
$token = $response['token'];

use Pushman\PHPLib\Pushman;
$pushman = new Pushman('private-key-goes-here');

$response = $pushman->channel('auth');
$max_connections = $response['max_connections'];

$response = $pushman->channels();
foreach($response as $channel) {
	echo("Found channel {$channel['name']}.\n");
}