PHP code example of gravitymedia / ssdp

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

    

gravitymedia / ssdp example snippets


// Initialize autoloader
ravityMedia\Ssdp\Client;
use GravityMedia\Ssdp\Event\DiscoverEvent;
use GravityMedia\Ssdp\Options\AliveOptions;
use GravityMedia\Ssdp\Options\DiscoverOptions;
use GravityMedia\Ssdp\UniqueServiceName;

// Create client
$client = new Client();

// Add listeners
$client->getEventDispatcher()
    ->addListener(DiscoverEvent::EVENT_DISCOVER, function (DiscoverEvent $event) {
        var_dump($event);
    });
$client->getEventDispatcher()
    ->addListener(DiscoverEvent::EVENT_DISCOVER_ERROR, function (DiscoverEvent $event) {
        var_dump($event->getException());
    });

// Create options
$options = new DiscoverOptions();

// Discover devices and services
$client->discover($options);
bash
$ php composer.phar 
 bash
$ php composer.phar install
 bash
$ php composer.phar test
 bash
$ php composer.phar install
 bash
$ php composer.phar doc