PHP code example of samaphp / lifxlan

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

    

samaphp / lifxlan example snippets


$light_ip = '192.168.1.x';
$Light = new Light($light_ip);
$brightness = 40;
$Light->setColorByName('white_warm', $brightness);

// Set light power on.
$Light->setPowerStatus('on');

// Set light power off.
$Light->setPowerStatus('off');

// Set a custom value for the connection timeout.
$Light->setTimeout(2);

// Custom timeout per method.
$Light->setTimeout(1)->setColorByName('white_cool', 10);