Code Monkey home page Code Monkey logo

lifx-php's Introduction

lifx-php

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

lifx-php is a PHP package for the LIFX HTTP API.

The author is not affiliated with LIFX and LIFX is not involved in the development of this package in any way.

Request for stakeholder comments! I am looking to gauge whether this package is still being used to decide whether to continue maintaining it. Please email me or open an issue to let me know whether you are looking to use any endpoints which are missing or whether you would like to see this package kept up to date.

Install

Via Composer

$ composer require kz/lifx-php

Laravel Configuration

lifx-php has optional support for Laravel and comes with a Service Provider and Facades for easy integration. The vendor/autoload.php is included by Laravel, so you don't have to require or autoload manually. Just see the instructions below.

After you have installed lifx-php, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package:

Kz\Lifx\LifxServiceProvider::class,

Add the facade of this package to the $aliases array:

'Lifx' => Kz\Lifx\LifxFacade::class,

Now the Lifx Class will be auto-loaded by Laravel.

You also need to supply your API Token in your .env environment file:

LIFX_TOKEN=0000000000000000000000000000000000000000000000000000000000000000

Usage

$api_token = 'token';
$lifx = new Kz\Lifx\Lifx($api_token);
$lifx->toggleLights();

Laravel Usage

// usage inside a laravel route
Route::get('/', function()
{
    $lifx = Lifx::all();

    return json_decode($lifx);
});

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

lifx-php's People

Contributors

hughbertd avatar jamesmills avatar kubacode avatar kz avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lifx-php's Issues

[Solved] Class 'Kz\Lifx' not found

Hi there,

on a fresh Composer install I'm getting a "Class 'Kz\Lifx' not found" error. Using PHP 5.5.30.

The test file includes just vendor/autoload.php and then your example from the README.

Checked Guzzle PHP with a simple example. Works without a glitch.

Where can I start in order to find the bug?

Best regards,
Krzysztof

Boolean default issue with new API

$persist = false,

I have noticed that with the upgrade to the new API that if I pass true/false as true boolean values the Lifx API is returning an error.

Lifx::breatheLights(
        $selector = 'all',
        $color = 'purple',
        $from_color = null,
        $period = 1.0,
        $cycles = 1.0,
        $persist = false,
        $power_on = true,
        $peak = 0.5
    )

"error": "persist does not have a valid value, power_on does not have a valid value"

However, if I change to send it like below, it works.

Lifx::breatheLights(
        $selector = 'all',
        $color = 'purple',
        $from_color = null,
        $period = 1.0,
        $cycles = 1.0,
        $persist = 'false',
        $power_on = 'true',
        $peak = 0.5
    )

Query Strings not sending?

@kz are the Query Strings for setLights, setColor, breatheLights & pulseLights methods sending the query string correctly for you? I've had to refactor the sendRequest method to accept an additional parameter with the query string, rather than the third parameter in a new Request.

I may have a different version of Guzzle installed compared to the version used to develop, so this could be the case of the issue - I'm currently running 6.0.1.

I'll pop through a PR with a fix if they aren't set correctly!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.