PHP client library for the LIFX API (v1) -- by, Chris Kankiewicz (@PHLAK)
LIFX Client is a LIFX API client library for PHP built with GuzzleHttp.
Refer to the full LIFX API documentation for more information about each method and it's available parameters.
- PHP >= 7.1
composer require phlak/lifx-client
First, import LIFX:
use PHLAK\LIFX;
Then instantiate the class with your LIFX OAuth 2 access token. You can generate an access token from your account settings page:
$lifx = new LIFX\Client('YOUR_APP_TOKEN');
List one or more lights via a selector:
$lifx->listLights($selector = 'all');
Set the state of one or more lights via a selector:
$lifx->setState($selector, array $params);
Set multiple states across multiple selectors:
$lifx->setStates(array $states, array $defaults = []);
Toggle the power of one or more lights via a selector:
$lifx->togglePower($selector, $duration = 1);
Cause one or more lights to breathe via a selector:
$lifx->breatheEffect($selector, $color, array $params = []);
Cause one or more lights to pulse via a selector:
$lifx->pulseEffect($selector, $color, array $params = []);
Make the light(s) cycle to the next or previous state in a list of states:
$lifx->cycle($selector, array $states, array $params = []);
Get a list of available scenes:
$lifx->listScenes();
Activate a scene:
$lifx->activateScene($sceneUuid, $duration = 1.0);
Validate a color string:
$lifx->validateColor($string);
use GuzzleHttp\Exception\ClientException;
try {
$lifx->togglePower('id:123456789abcd');
} catch (ClientException $exception) {
// Handle this exception here...
}
See the GuzzleHttp exceptions documentation for more details.
A list of changes can be found on the GitHub Releases page.
For general help and support join our [Spectrum Community](https://spectrum.chat/phlaknet or reach out on Twitter.
Please report bugs to the GitHub Issue Tracker.
This project is licensed under the MIT License.