Go to file
Noccy 116233d81a Bugfixes 2017-03-31 16:45:52 +02:00
bin Bugfixes 2017-03-31 16:45:52 +02:00
examples Initial commit 2017-02-16 16:29:55 +01:00
src Bugfixes 2017-03-31 16:45:52 +02:00
.gitignore Initial commit 2017-02-16 16:29:55 +01:00
LICENSE Initial commit 2017-02-16 16:29:55 +01:00
README.md Various improvements 2017-02-18 13:12:36 +01:00
composer.json Added upnp-discover cli tool 2017-02-16 17:40:02 +01:00


UPnP Library for PHP

This is a UPnP client implementation in native PHP. It currently supports basic discovery and device enumeration.

Implemented Features


The HTTPU implementation is used by UPnP to send HTTP-like messages over UDP. It consist of an Endpoint class that creates a listening socket and classes and subclasses for Request and Response.

Currently only MSearchRequest and MSearchResponse is implemented. These classes are used to send M-SEARCH messages for discovery, and to parse the response.


The SSDP (Simple Service Discovery Protocol) implementation is used to find devices on the local network, and to enumerate child devices and defined services.

To discover devices, use the Discovery class, and call discover() with the search target as the first parameter. The SearchTarget class contains constants and methods to help with resolving and constructing search types.

Once the discovery has completed, you can iterate over the Discovery object to get the devices.

use NoccyLabs\UPnP\SSDP\Discovery;
use NoccyLabs\UPnP\SSDP\SearchTarget;

$discovery = new Discovery();

foreach ($discovery as $device) {

Experimental Features


The DCPs (Device Control Protocol) are used to interact with services. This can be f.ex. managing UPnP portmapping in your router or controlling a media player.

Search targets

To find everything, use ALL:


Find all root devices:


Find Internet Gateway Devices (routers). This equates to the type string urn:schemas-upnp-org:device:InternetGatewayDevice:<version>. Version 1 of the IGD specification has been deprecated, so you probably want to use version 2 when discovering devices:


You can also find devices based on UUIDs:

    -> "uuid:<uuid>"

Or devices based on the core UPnP schemas or device classes:

SearchTarget::URN_SCHEMA_DEVICE(<type>, <version>)
    -> "urn:schemas-upnp-org:device:<type>:<version>"
SearchTarget::URN_SCHEMA_SERVICE(<type>, <version>)
    -> "urn:schemas-upnp-org:service:<type>:<version>"

For example, to find the devices returned by URN_SCHEMA_DEVICE_IGD_2 you could use:


Additionally, you can search for vendor specific services or device classes:

SearchTarget::URN_DEVICE(<domain>, <type>, <version>)
    -> "urn:<domain>:device:<type>:<version>"
SearchTarget::URN_SERVICE(<domain>, <type>, <version>)
    -> "urn:<domain>:service:<type>:<version>"

For example, to find DIAL devices (for "casting" Netflix, YouTube etc. on TV) you could use:

SearchTarget::URN_DEVICE('dial-multiscreen-org', 'dialreceiver', 1)