StatusBoard
StatusBoard is a small PHP library that helps you render StatusBoard widgets like
graphs and tables. It provides classes to handle tables, graphs and DIY widgets., (*1)
, (*2)
The library is built with a service-oriented architecture in mind. The renderers can easily be defined as services in
you favorite framework and the decoupled code enables you to override any classes with your own implementation in a
pinch., (*3)
Usage
<?php
require '../vendor/autoload.php';
// Create a Table widget
$widget = new StatusBoard\Widget\TableWidget();
$widget->setRows(array(
array('Project', 'Version', 'Lang', 'Status'),
array('StatusBoard', '0.1.0', 'PHP', 'Ok'),
array('ObHighchartsBundle', '1.0.0', 'PHP', 'Fail')
));
// Register an HTML renderer
// You could also easily write your own renderer if the stock one doesn't fit your needs
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
new StatusBoard\Renderer\HtmlRenderer()
));
echo $renderer->render($widget);
Add the table to StatusBoard app and you get this:, (*4)
, (*5)
See the official Table tutorial for more infos., (*6)
<?php
require '../vendor/autoload.php';
// Register a Json renderer
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
new StatusBoard\Renderer\JsonRenderer()
));
// Create a Graph widget
$widget = new StatusBoard\Widget\GraphWidget();
$data1 = new \StatusBoard\Model\GraphData();
$data2 = new \StatusBoard\Model\GraphData();
// First dataset
$data1->setTitle('Visits')
->setColor('blue')
->addDataPoint('2012', 3963)
->addDataPoint('2013', 4561);
// Second dataset
$data2->setTitle('Unique Visits')
->setColor('orange')
->addDataPoint('2012', 2105)
->addDataPoint('2013', 3001);
$widget->setTitle("Visits")
->showTotal(true)
->addDataPoints($data1)
->addDataPoints($data2);
header('Content-Type: application/json');
echo $renderer->render($widget);
Add the graph to StatusBoard app and you get this:, (*7)
, (*8)
See the official Graph tutorial for more infos., (*9)
<?php
require '../vendor/autoload.php';
// Create a DIY widget
$widget = new StatusBoard\Widget\DiyWidget();
// You should get your HTML from a template engine
$widget->setHtml('
<style type="text/css">
html,
body,
.container {
margin: 0;
padding: 0;
overflow: hidden;
}
body {
color: white;
font-family: Roadgeek2005SeriesC, sans-serif;
}
.container {
text-align: center;
}
h1 {
font-size: 60px;
line-height: 120px;
margin-top: 50px;
}
</style>
<div class="container">
<h1>HTML!</h1>
</div>
');
// Register an HTML renderer
$renderer = new StatusBoard\Renderer\WidgetRenderer();
$renderer->setRenderers(array(
new StatusBoard\Renderer\HtmlRenderer()
));
echo $renderer->render($widget);
Add the graph to StatusBoard app and you get this:, (*10)
, (*11)
See the official DIY tutorial for more infos., (*12)
Installation
-
Run composer require ob/statusboard, (*13)
-
Now, you just have to require the autoloader in your project to have access to the library:, (*14)
<?php
require 'vendor/autoload.php';
VoilĂ !, (*15)
Requirements
Contributing
See the CONTRIBUTING.md file., (*16)
Running the tests
If not done already, install the dependencies and generate the autoloader with composer:, (*17)
$ curl -sS https://getcomposer.org/installer | php
$ composer install --dev
Once installed, just run the following command:, (*18)
$ phpunit
You can also check for code coverage:, (*19)
$ phpunit --coverage-text
Credits
Thanks to Panic for their affordable, easy to hack StatusBoard
application., (*20)
License
StatusBoard is released under the MIT License. See the bundled LICENSE file for details., (*21)