Sonos A PHP library for interacting with Sonos speakers

Getting Started

Usage

Controllers

Services

Fun Stuff

Cache

View the API Documentation for this class

By default the library will search your network for speakers each time your script runs.
This search can take a couple of seconds, so you may want to use a CachedCollection to avoid doing the search every time.

The caching is handled by PSR-16, you’ll need to install an implementation using composer.

# First create a device collection that auto discovers devices from the network
$collection = new Discovery();

# Get your PSR-16 implementation
$cache = new \Symfony\Component\Cache\Simple\FilesystemCache;

# Create a cached collection that wraps our auto discovery one.
$collection = new CachedCollection($collection, $cache);

# Finally create your network instance using the cached collection
$sonos = new Network($collection);

This will speed up your scripts, but it can also cause problems if you add/remove devices from your network.