PHP code example of sfm / ducksboard-bundle
1. Go to this page and download the library: Download sfm/ducksboard-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sfm / ducksboard-bundle example snippets
$bundles = array(
...
new SFM\DucksboardBundle\SFMDucksboardBundle(),
...
);
[DucksboardBundle]
git=https://github.com/mgallego/DucksboardBundle.git
target=/bundles/SFM/DucksboardBundle
$loader->registerNamespaces(array(
...
'SFM' => __DIR__.'/../vendor/bundles',
...
$bundles = array(
...
new SFM\DucksboardBundle\SFMDucksboardBundle(),
...
);
ducksboard_api = xxxxxxxxxxxxxxx
services:
...
...
example.ducksboard:
class: SFM\DucksboardBundle\Adapter\Widget
arguments: [@sfm.ducksboard.connector]
calls:
- [setApiKey, [%ducksboard_api%]]
$widget = $this->container->get('sfm.ducksboard.widget');
$widget->setApiKey($this->container->getParameter('ducksboard_api'));
$widget = $this->container->get('screencast.ducksboard');
$widget->setData(array($widgetID => array('value' => $val1)));
$widget->push();
$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();
$widget = $this->container->get('screencast.ducksboard');
$widgetData = array($widgetId => array('delta' => 1 ));
$widget->setData($widgetData);
$widget->push();
$widget->getLastValues($widgetId, 3);
$widgetActualData = $widget->getArrayResponse();
//or
$widgetActualData = $widget->getRawResponse();
$widget->findBySeconds($widgetId, $seconds);
$widgetActualData = $widget->getArrayResponse();
//or
$widgetActualData = $widget->getRawResponse();
$widget->findByTimespan($widgetId, 'monthly', $timezone);
$widgetActualData = $widget->getArrayResponse();
//or
$widgetActualData = $widget->getRawResponse();