carlosio / alexa
A PHP library for getting performance indicator from Alexa (http://www.alexa.com)
dev-master
2014-02-13 16:46 UTC
Requires
- fabpot/goutte: 1.0.*@dev
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-11-22 04:22:39 UTC
README
A PHP library for dealing with Geckoboard API (http://www.geckoboard.com)
Installation
The best way to install the library is by using Composer. Add the following to composer.json
in the root of your project:
{ "require": { "carlosio/geckoboard": "dev-master" } }
Then, on the command line:
curl -s http://getcomposer.org/installer | php
php composer.phar install
Use the generated vendor/autoload.php
file to autoload the library classes.
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use CarlosIO\Geckoboard\Widgets\NumberAndSecondaryStat; use CarlosIO\Geckoboard\Client; $myWidget = new NumberAndSecondaryStat(); $myWidget->setId('<your widget id>'); $myWidget->setMainValue(123); $myWidget->setSecondaryValue(238); $myWidget->setMainPrefix('EUR'); $geckoboardClient = new Client(); $geckoboardClient->setApiKey('<your token>'); $geckoboardClient->push($myWidget);
Widget: Number and optional secondary stat
use CarlosIO\Geckoboard\Widgets\NumberAndSecondaryStat; use CarlosIO\Geckoboard\Client; $myWidget = new NumberAndSecondaryStat(); $myWidget->setId('<your widget id>'); $myWidget->setMainValue(123); $myWidget->setSecondaryValue(238); $myWidget->setMainPrefix('EUR'); $geckoboardClient = new Client(); $geckoboardClient->setApiKey('<your token>'); $geckoboardClient->push($myWidget);
Widget: RAG numbers only
use CarlosIO\Geckoboard\Data\Entry; use CarlosIO\Geckoboard\Widgets\RagNumbers; use CarlosIO\Geckoboard\Client; $myWidget = new RagNumbers(); $myWidget->setId('<your widget id>'); $redData = new Entry(); $redData->setValue(132)->setText('This is the red description'); $myWidget->setRedData($redData); $amberData = new Entry(); $amberData->setValue(134)->setText('This is the amber description'); $myWidget->setAmberData($amberData); $greenData = new Entry(); $greenData->setValue(34)->setText('This is the green description'); $myWidget->setGreenData($greenData); $geckoboardClient->push($myWidget);
Widget: RAG column and numbers
use CarlosIO\Geckoboard\Data\Entry; use CarlosIO\Geckoboard\Widgets\RagColumnAndNumbers; use CarlosIO\Geckoboard\Client; $myWidget = new RagColumnAndNumbers(); $myWidget->setId('<your widget id>'); $redData = new Entry(); $redData->setValue(132)->setText('This is the red description'); $myWidget->setRedData($redData); $amberData = new Entry(); $amberData->setValue(13)->setText('This is the amber description'); $myWidget->setAmberData($amberData); $greenData = new Entry(); $greenData->setValue(3)->setText('This is the green description'); $myWidget->setGreenData($greenData); $geckoboardClient->push($myWidget);
Widget: Text
use CarlosIO\Geckoboard\Widgets\Text; use CarlosIO\Geckoboard\Data\Text\Item; use CarlosIO\Geckoboard\Client; $myWidget = new Text(); $firstItem = new Item(); $secondItem = new Item(); $firstItem->setText('Test message 1'); $secondItem->setText('Test message 2'); $secondItem->setType(Item::TYPE_ALERT); $myWidget->addItem($firstItem); $myWidget->addItem($secondItem); $geckoboardClient->push($myWidget);
Widget: Funnel
use CarlosIO\Geckoboard\Data\Funnel\Entry; use CarlosIO\Geckoboard\Widgets\Funnel; $myWidget = new Funnel(); $myWidget->setId('29473-d7ae87e3-ac3f-4911-95ce-ec91439a4170'); $myWidget->setType('reversed'); $myWidget->setShowPercentage(false); $error = new Entry(); $error->setLabel('Step 1')->setValue(87809); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 2')->setValue(70022); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 3')->setValue(63232); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 4')->setValue(53232); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 5')->setValue(32123); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 6')->setValue(23232); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 7')->setValue(12232); $myWidget->addEntry($error); $error = new Entry(); $error->setLabel('Step 8')->setValue(2323); $myWidget->addEntry($error); $geckoboardClient->push($myWidget);
Testing
In order to run the test, update php composer.phar update --dev
$ bin/phpunit --coverage-text