PHP Classes

DashOne: Compose and display a dashboard programmatically

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (25)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 237 This week: 1All time: 8,056 This week: 560Up
Version License PHP version Categories
dashone 1.0.1GNU Lesser Genera...5HTML, PHP 5, Content management
Description 

Author

This package can compose and display a dashboard only with PHP code.

It provides several classes that implement different types of controls that can be used to compose and render a complex dashboard.

Currently it provides controls to display alerts, buttons, containers, form, images, links and tables.

Picture of Jorge Castro
  Performance   Level  
Name: Jorge Castro <contact>
Classes: 30 packages by
Country: Chile Chile
Age: 48
All time rank: 12763 in Chile Chile
Week rank: 106 Up1 in Chile Chile Up
Innovation award
Innovation award
Nominee: 14x

Winner: 2x

Example

<?php

use eftec\DashOne\controls\ContainerOne;
use
eftec\DashOne\controls\ControlOne;
use
eftec\DashOne\controls\ButtonOne;
use
eftec\DashOne\controls\ImageOne;
use
eftec\DashOne\DashOne;
use
eftec\DashOne\controls\LinkOne;
use
eftec\DashOne\controls\UlOne;
use
eftec\DashOne\controls\FormOne;
use
eftec\DashOne\controls\TableOne;

include
"../vendor/autoload.php";

$valueUL=['Cocacola','Fanta','Sprite'];

$values=
    [
        [
'IdProduct'=>1,'Name'=>'Cocacola','Price'=>"20.2","Buttons"=>[new LinkOne('button1','#','icon')]],
        [
'IdProduct'=>2,'Name'=>'Fanta','Price'=>"30.5",[new ButtonOne('https://www.google.cl',"click",'btn btn-danger btn-sm','link')]],
        [
'IdProduct'=>3,'Name'=>'Sprite','Price'=>"11.5"],
    ];

$definitionsTable=['IdProduct'=>'Id. of the Product'
   
,'Name'=>'Name'
   
,'Price'=>'Price in USD'
   
,'Buttons'=>'Edit'];


$definition=['IdProduct'=>'hidden'
   
,'Name'=>'text'
   
,'Price'=>'text'
   
,'Type'=>['cocacola','fanta','sprite']
    ,
'Description'=>'textarea'];
$currentValue=['IdProduct'=>"2"
   
,'Name'=>"aaa"
   
,'Price'=>"333"
   
,'Type'=>1
   
,'Description'=>''];

$buttons=[
    new
ButtonOne('button1','Click me','btn btn-primary'),
    new
ButtonOne('button2','Click me too','btn btn-danger')
];

$links=[
    new
LinkOne('Link1','#','far fa-star'),
    new
LinkOne('Link2','#','far fa-star'),
    new
LinkOne('Link3','#','far fa-star')
];

$dash=new DashOne();

$dash->head('Example - test 1');
$dash->menuUpper(
    [new
ImageOne('https://via.placeholder.com/32x32')," - ",new LinkOne('Fanta','#','','text-light')]
,[new
LinkOne('Fanta','#','','text-light'),' ',new LinkOne('Fanta','#','','text-light'),' ',new LinkOne('Fanta','#','','text-light')]);
$dash
   
->startcontent()
        ->
menu($links)
        ->
startmain()
            ->
title('Table of Products')
            ->
rawHtml('<br>')
            ->
table($values,$definitionsTable)->setClass('table table-stripped')->setId('table1')
            ->
title('Form')
            ->
rawHtml('<br>')
            ->
form($currentValue)
            ->
rawHtml('<br>')
            ->
rawHtml('<br>')
            ->
link("Go to google","https://www.google.com","far fa-star")
            ->
rawHtml('<br>')
            ->
rawHtml('<br>')
            ->
buttons($buttons,false)
            ->
rawHtml('<br><br>')
            ->
ul($valueUL)
            ->
rawHtml("<br><br>")
            ->
alert('title','subtitle')
        ->
endmain()
    ->
endcontent();
$dash->footer();
$dash->render();


Details

DashOne

A minimalist dashboard /backend library for PHP

This library allows to create a fast dashboard with the basic features without any template and only using code. In the examples, we create a page for a dashboard in less than 80 lines of code ( examples/test.php )

Build Status Packagist Total Downloads [Maintenance]() [composer]() [php]() [php]() [CocoaPods]()

Example ( examples/test.php ):

doc/screenshot1.jpg

Another example ( examples/test.php ):

doc/screenshot2.jpg

Getting started

Install via composer

> composer require eftec/dashone

Create a new object DashOne (you will need to add the required include, via autoload.php or manually)

> $dash=new DashOne();

And you could render a page using the object of the class DashOne()

use eftec\DashOne\DashOne;
$dash=new DashOne();
$dash->head('Example - test 1'); // it is required
$dash->rawHtml('hello world'); 
$dash->footer(); // it is required
$dash->render(); // it renders an empty page

Classes

DashOne

It is the main class that generates the dashboard.

> $dash=new DashOne();

It is possible to add new elements using fluent interface (chain methods each one).

Example: It renders an empty page

use eftec\DashOne\DashOne;
$dash=new DashOne();

$dash->head('Example - test 1');
$dash->footer();
$dash->render();

Example using fluent

use eftec\DashOne\DashOne;
$dash=new DashOne();
$dash->head('Example - test 1')
    ->footer()
    ->render();

Where the method head is required to render the < head > of the page.

The footer is also required to close all the tags.

And every chain of methods must end with the method render() (it draw the page).

// see examples/testuibasic.php
$dash=new DashOne();
$dash->head('Example - test 1')
	->menuUpper(['Upper title'])
	->startcontent()
	->menu($links) // left menu
	->startmain()
	// here it goes the content
	->endmain()
	->endcontent()
	->footer()
	->render();		

doc/screenshotdashboardempty.jpg

Method DashOne->head($title,$extrahtml)

It renders the head of the page. This element is required

> $dash->head('Example - test 1');

Method DashOne->menuUpper($leftControls=[],$rightControls=[])

It renders the upper menu of the dashboard.

> $dash->menuUpper([new ImageOne('https://via.placeholder.com/32x32')," - ",new LinkOne('Cocacola','#')]);

AlertOne

It renders an alert

> new AlertOne($title,$content,$class);

Example:

$dash->alert("It is an alert","Content of the alert")

doc/screenshotalert.jpg

$dash->alert("It is an alert","Content of the alert","alert alert-danger")

doc/screenshotalert2.jpg

ButtonOne

It renders a button

> new ButtonOne('button1','Click me','btn btn-primary');

You could use the method buttons (DashOne) to render a button (or buttons). The method has a second argument to determine if the buttons must be aligned or not with the form.


$buttons=[
	new ButtonOne('button1','Click me','btn btn-primary'),
	new ButtonOne('button2','Click me too','btn btn-danger')
];


$dash->buttons($buttons,false) // where if true then buttons are aligned with the form

> $dash->buttons($buttons,true)

doc/screenshotbutton1.jpg

> $dash->buttons($buttons,false)

doc/screenshotbutton2.jpg

ContainerOne

It renders a container where it is possible to add other elements (such as buttons)

> new ContainerOne($html);

Example:

	$dash->container("<div class='form-group row'><div class='col-sm-10 offset-sm-2'>%control</div></div>")
		->buttons($buttons)

The method container() but be followed by a visual method. This method is added inside the container (where it says %control)

Another example:

	$dash->container("<hr>%control<hr>")->rawHtml("hello world")

doc/screencontainer.jpg

FormOne

It renders a form. It requires a declarative array.

If it sets a definition, then it uses the definition to define the types of input objects (textbox,textarea,etc.)

If a field of the definition has an array then it is used to render a dropdownitem

If it doesn't have a definition then, it uses the values to define the types of input objects (textboxes,textareas,etc.)

You could also render a message (for example for warning or information) You could draw a form using an associative array. By default, every field will be a textbox

$currentValue=['IdProduct'=>"2"
	,'Name'=>"aaa"
	,'Price'=>"333"
	,'Type'=>1
	,'Description'=>''];

$dash->form($currentValue) // it's macro of new FormOne()

doc/screenshotform0.jpg

Or you could explicit the type of field

$definition=['IdProduct'=>'hidden'
	,'Name'=>'text'
	,'Price'=>'text'
	,'Type'=>['cocacola','fanta','sprite']
	,'Description'=>'textarea'];
$currentValue=['IdProduct'=>"2"
	,'Name'=>"aaa"
	,'Price'=>"333"
	,'Type'=>1
	,'Description'=>''];

$dash->form($currentValue,$definition) // it's macro of new FormOne()

doc/screenshotform.jpg

UlOne

It draws a list (unsorted list)

$valueUL=['Cocacola','Fanta','Sprite'];

$dash->ul($valueUL) // it's macro of new UlOne()

doc/screenshotul.jpg

ImageOne

It draws a image

> new ImageOne('https://via.placeholder.com/32x32');

https://via.placeholder.com/32x32

LinkOne

It draws a hyperlink

The first value is the name of the link, the second is the address. And the third value (optional), it's a icon (using the classes of Font-Awesome)

> new LinkOne('Cocacola','#','far fa-star') > $dash->link('Cocacola','#','far fa-star')

doc/link.jpg

TableOne

it renders a table.

$values=
	[
		['IdProduct'=>1,'Name'=>'Cocacola','Price'=>"20.2"],
		['IdProduct'=>2,'Name'=>'Fanta','Price'=>"30.5"],
		['IdProduct'=>3,'Name'=>'Sprite','Price'=>"11.5"],
	];

$dash->table($values)->...  // it must be called after the render

doc/screenshottable.jpg

A basic page :

Any pages requires at least to call the head(), footer() and Render().

Render() draws the page so it must be called at the end of the chain.

For example, a basic page is as follow:

$dash=new DashOne();

$dash->head('Example - test 1');
$dash->footer();
$dash->render();

An empty dashboard:

$dash=new DashOne();

$dash->head('Example - test 1');
$dash->menuUpper([new ImageOne('https://via.placeholder.com/32x32')," - ",new LinkOne('Cocacola','#')]);
$dash
	->startcontent() // start the container
		->menu($links) // left menu
		->startmain() // start the main container
			->title('Table of Products')
		->endmain()
	->endcontent();
$dash->footer();
$dash->render();

Version

  • 1.6 2020-18-01 * modified LinkOne::LinkOne() * added summernote to textarea
  • 1.5 2020-16-01 * new method getLogin() * new method logout()
  • 1.4 2020-16-01 * new method cssLogin() * new method login() * new method fetchLogin() * new method decrypt() * new method encrypt() * new field var $salt=''; * new field $validateLogin (callable) * changes to __construct()
  • 1.3 2020-01-15 new method fetchvalue()
  • 1.2 2019-03-30 New changes.
  • 1.1 2019-03-17 Fixed some bugs
  • 1.0 2019-03-01 First Version.

Copyright

Copyright Jorge Patricio Castro Castillo <jcastro arroba eftec dot cl> Dual License (LGPL v3 and Commercial License)

You could use in commercial / close source product or service while

In a nutshell (it is the license):

  • You must keep the copyright notices.
  • If you modify the library then you must share the changes and modifications.

Screenshots  
  • doc/screencontainer.jpg
  • doc/screenshot1.jpg
  • doc/screenshot2.jpg
  • doc/screenshotalert.jpg
  • doc/screenshotalert2.jpg
  • doc/screenshotbutton1.jpg
  • doc/screenshotbutton2.jpg
  • doc/screenshotdashboardempty.jpg
  • doc/screenshotform.jpg
  • doc/screenshotform0.jpg
  • doc/screenshottable.jpg
  • doc/screenshottable2.jpg
  • doc/screenshotul.jpg
  Files folder image Files  
File Role Description
Files folder imagedoc (1 file)
Files folder imageexamples (6 files, 1 directory)
Files folder imagelib (1 file, 1 directory)
Files folder imagetests (2 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  doc  
File Role Description
  Accessible without login Image file link.jpg Icon Icon image

  Files folder image Files  /  examples  
File Role Description
Files folder imagefullexample (1 file)
  Accessible without login Plain text file test.php Example Example script
  Accessible without login Plain text file test2.php Example Example script
  Accessible without login Plain text file testlogin.php Example Example script
  Accessible without login Plain text file testlogin2.php Aux. Auxiliary script
  Accessible without login Plain text file testlogin3.php Aux. Auxiliary script
  Accessible without login Plain text file testuibasic.php Example Example script

  Files folder image Files  /  examples  /  fullexample  
File Role Description
  Accessible without login Plain text file dashboard.php Example Example script

  Files folder image Files  /  lib  
File Role Description
Files folder imagecontrols (9 files)
  Plain text file DashOne.php Class Class source

  Files folder image Files  /  lib  /  controls  
File Role Description
  Plain text file AlertOne.php Class Class source
  Plain text file ButtonOne.php Class Class source
  Plain text file ContainerOne.php Class Class source
  Plain text file ControlOne.php Class Class source
  Plain text file FormOne.php Class Class source
  Plain text file ImageOne.php Class Class source
  Plain text file LinkOne.php Class Class source
  Plain text file TableOne.php Class Class source
  Plain text file UlOne.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file bootstrap.php Class Class source
  Plain text file DashOneTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:237
This week:1
All time:8,056
This week:560Up
User Comments (1)
Thats a amazing class, congratulations !
4 years ago (José Filipe Lopes Santos)
80%StarStarStarStarStar