Recommend this page to a friend! |
Download |
Info | Example | Screenshots | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 237 | All time: 8,067 This week: 455 |
Version | License | PHP version | Categories | |||
dashone 1.0.1 | GNU Lesser Genera... | 5 | HTML, PHP 5, Content management |
Description | Author | |
This package can compose and display a dashboard only with PHP code. |
<?php |
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 )
Example ( examples/test.php ):
Another example ( examples/test.php ):
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
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();
It renders the head of the page. This element is required
> $dash->head('Example - test 1');
It renders the upper menu of the dashboard.
> $dash->menuUpper([new ImageOne('https://via.placeholder.com/32x32')," - ",new LinkOne('Cocacola','#')]);
It renders an alert
> new AlertOne($title,$content,$class);
Example:
$dash->alert("It is an alert","Content of the alert")
$dash->alert("It is an alert","Content of the alert","alert alert-danger")
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)
> $dash->buttons($buttons,false)
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")
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()
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()
It draws a list (unsorted list)
$valueUL=['Cocacola','Fanta','Sprite'];
$dash->ul($valueUL) // it's macro of new UlOne()
It draws a image
> new ImageOne('https://via.placeholder.com/32x32');
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')
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
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();
$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();
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):
Screenshots (13) | ||
Files (38) |
File | Role | Description | ||
---|---|---|---|---|
doc (1 file) | ||||
examples (6 files, 1 directory) | ||||
lib (1 file, 1 directory) | ||||
tests (2 files) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (38) | / | examples |
File | Role | Description | ||
---|---|---|---|---|
fullexample (1 file) | ||||
test.php | Example | Example script | ||
test2.php | Example | Example script | ||
testlogin.php | Example | Example script | ||
testlogin2.php | Aux. | Auxiliary script | ||
testlogin3.php | Aux. | Auxiliary script | ||
testuibasic.php | Example | Example script |
Files (38) | / | lib | / | controls |
File | Role | Description |
---|---|---|
AlertOne.php | Class | Class source |
ButtonOne.php | Class | Class source |
ContainerOne.php | Class | Class source |
ControlOne.php | Class | Class source |
FormOne.php | Class | Class source |
ImageOne.php | Class | Class source |
LinkOne.php | Class | Class source |
TableOne.php | Class | Class source |
UlOne.php | Class | Class source |
Files (38) | / | tests |
File | Role | Description |
---|---|---|
bootstrap.php | Class | Class source |
DashOneTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Comments (1) | |||||
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.