sfm / ducksboard-bundle
Symfony2 Bundle to integrate an app with Ducksboard.
Installs: 445
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=5.3.0
- symfony/symfony: >=2.0
This package is not auto-updated.
Last update: 2025-03-09 04:10:12 UTC
README
This bundle integrates Symfony2 applications with the Ducksboard API.
Dependencies
PHP Curl library http://php.net/manual/en/book.curl.php
Instalation
With composer
Add the project in the composer.json
file:
... "require": { ... "sfm/ducksboard-bundle": "dev-master" ... }
and in the AppKernel.php
file:
$bundles = array( ... new SFM\DucksboardBundle\SFMDucksboardBundle(), ... );
Execute php composer.phar install
With deps files
Add the project in the deps
file:
[DucksboardBundle] git=https://github.com/mgallego/DucksboardBundle.git target=/bundles/SFM/DucksboardBundle
and in the `autoload.php' file:
$loader->registerNamespaces(array( ... 'SFM' => __DIR__.'/../vendor/bundles', ...
and in the AppKernel.php
file:
$bundles = array( ... new SFM\DucksboardBundle\SFMDucksboardBundle(), ... );
Use like an own service
First you need to include the Ducksboard apiKey into the parameters
file (ini/yml):
ducksboard_api = xxxxxxxxxxxxxxx
Second, create the service:
services: ... ... example.ducksboard: class: SFM\DucksboardBundle\Adapter\Widget arguments: [@sfm.ducksboard.connector] calls: - [setApiKey, [%ducksboard_api%]]
Now you can use your own service that set automatically the apikey
Use the bundle service
The bundle has a service prepared to use. Example:
$widget = $this->container->get('sfm.ducksboard.widget'); $widget->setApiKey($this->container->getParameter('ducksboard_api'));
Examples of use
Push method
Simple Widget
$widget = $this->container->get('screencast.ducksboard'); $widget->setData(array($widgetID => array('value' => $val1))); $widget->push();
Double Widget
$widget = $this->container->get('screencast.ducksboard'); $dateData1 = array( array('timestamp' => time(), 'value' => '130'), array('timestamp' => time() - ((24*60*60)) , 'value' => '50'), array('timestamp' => time() - ((2*24*60*60)) , 'value' => '70'), array('timestamp' => time() - ((3*24*60*60)) , 'value' => '20'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '50'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '80'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '100')); $dateData2 = array( array('timestamp' => time(), 'value' => '80'), array('timestamp' => time() - ((24*60*60)) , 'value' => '20'), array('timestamp' => time() - ((2*24*60*60)) , 'value' => '70'), array('timestamp' => time() - ((3*24*60*60)) , 'value' => '80'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '50'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '90'), array('timestamp' => time() - ((4*24*60*60)) , 'value' => '30')); $widgetGraphData = array( $widgetId1=> $dateData1, $widgetId2 => $dateData2 ); $widget->setData($widgetGraphData); $widget->push();
Delta Values
$widget = $this->container->get('screencast.ducksboard'); $widgetData = array($widgetId => array('delta' => 1 )); $widget->setData($widgetData); $widget->push();
Pull method
Get the 3 last data of a widget
$widget->getLastValues($widgetId, 3); $widgetActualData = $widget->getArrayResponse(); //or $widgetActualData = $widget->getRawResponse();
Find data by seconds
$widget->findBySeconds($widgetId, $seconds); $widgetActualData = $widget->getArrayResponse(); //or $widgetActualData = $widget->getRawResponse();
Find data by timespan
$widget->findByTimespan($widgetId, 'monthly', $timezone); $widgetActualData = $widget->getArrayResponse(); //or $widgetActualData = $widget->getRawResponse();
Other resources
Oficial Ducskboard API documentation: http://ducksboard.com/our-apis/
A Demo video with examples (spanish): https://vimeo.com/46636287