2017 © Pedro Peláez
 

library spark

PHP library for the Spark.io API

image

wensleydale/spark

PHP library for the Spark.io API

  • Thursday, March 20, 2014
  • by garethtdavies
  • Repository
  • 7 Watchers
  • 17 Stars
  • 53 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

SparkPHP

Build Status Scrutinizer Quality Score Code Coverage, (*1)

PHP library for the Spark.io API., (*2)

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., (*3)

More detailed examples will follow shortly but basic operations may be found in the examples directory., (*4)

Turning on a LED using default tinker firmware

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

Installing via Composer

The recommended way to install the library is through Composer., (*5)

# Install Composer
curl -sS https://getcomposer.org/installer | php

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

After installing, you need to require Composer's autoloader:, (*6)

require 'vendor/autoload.php';

Managing Tokens

You may list all your tokens, generate a token or delete a token, (*7)

$tokenInstance = SparkCore::token();
$tokenInstance->setUsername('your_spark_username');
$tokenInstance->setPassword('your_spark_password');
$listTokens = $tokenInstance->listTokens();

Exceptions

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., (*8)

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, (*9)

The Versions

20/03 2014

dev-master

9999999-dev

PHP library for the Spark.io API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Davies

spark