PHP library for the API

dev-master 2014-03-20 19:50 UTC

This package is not auto-updated.

Last update: 2021-02-19 20:27:14 UTC


Build Status Scrutinizer Quality Score Code Coverage

PHP library for the API.

Makes it incredibly easy to get up and running using the default Tinker firmware or any custom function/variable that is exposed by your core firmware. You can also use the library to access/generate tokens and flash firmware to your core.

More detailed examples will follow shortly but basic operations may be found in the examples directory.

Turning on a LED using default tinker firmware

$core = SparkCore::make($accessToken);
$core->digitalWrite(); //Will turn on the inbuilt LED

Installing via Composer

The recommended way to install the library is through Composer.

# Install Composer
curl -sS | php

# Add Spark as a dependency
php composer.phar require wensleydale/spark:dev-master

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Managing Tokens

You may list all your tokens, generate a token or delete a token

$tokenInstance = SparkCore::token();
$listTokens = $tokenInstance->listTokens();


If there are any issues during the API request a SparkException or SparkTokenException will be thrown which can be caught and managed according to your application needs.

Unit Tests

This library uses PHPUnit for unit testing. In order to run the unit tests, you'll first need to install the dependencies of the project using Composer: php composer.phar install --dev. You can then run the tests using vendor/bin/phpunit. The library comes with a set of mocked responses from the Spark API