PHPackages                             eftec/dashone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. eftec/dashone

ActiveLibrary[Templating &amp; Views](/categories/templating)

eftec/dashone
=============

A fast UI Dashboard generator for PHP

1.7(6y ago)68011LGPL-3.0-or-laterPHPPHP &gt;=5.6CI failing

Since Mar 14Pushed 6y ago2 watchersCompare

[ Source](https://github.com/EFTEC/DashOne)[ Packagist](https://packagist.org/packages/eftec/dashone)[ Docs](https://github.com/EFTEC/DashOne)[ RSS](/packages/eftec-dashone/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (1)Versions (11)Used By (0)

DashOne
=======

[](#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](examples/test.php) )

[![Build Status](https://camo.githubusercontent.com/3fdc81d9654d6e8d1a68aa569e3cd27586201de7aa68e13a51441fd57841e511/68747470733a2f2f7472617669732d63692e6f72672f45465445432f446173684f6e652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/EFTEC/DashOne)[![Packagist](https://camo.githubusercontent.com/cf3a063fe0a4c9d0973a364802ccb3799875572510d629a887761266fbcc7fdd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65667465632f646173686f6e652e737667)](https://packagist.org/packages/eftec/dashone)[![Total Downloads](https://camo.githubusercontent.com/d1fc187968c91615c892e22430cab8adca21dbef4bcecce6e133b37c455392e6/68747470733a2f2f706f7365722e707567782e6f72672f65667465632f646173686f6e652f646f776e6c6f616473)](https://packagist.org/packages/eftec/dashone)![Maintenance](https://camo.githubusercontent.com/0080c39e8991e448d139858f9038668b6078ad14a26bacb65acf2ec3bfa9d661/68747470733a2f2f696d672e736869656c64732e696f2f6d61696e74656e616e63652f7965732f323032302e737667)![composer](https://camo.githubusercontent.com/08623182d7b037246f11c0ad4aec3fe405dcf9d668058398497abd1a9a770e9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6d706f7365722d253345312e362d626c75652e737667)![php](https://camo.githubusercontent.com/62fb387978945851f2340aa880bfc2a4164d74b4efcdf06b40833d91998dd145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345352e362d677265656e2e737667)![php](https://camo.githubusercontent.com/0d20998129714e2662748003f3e0fab165e7f10d9dd4eb097376217b12c07b15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e782d677265656e2e737667)![CocoaPods](https://camo.githubusercontent.com/347353606ed8f26b45bcf9da083db0063fa1dadd1baef36a5f3bf9ce1d127548/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d37302532352d79656c6c6f772e737667)

Example ( [examples/test.php](examples/test2.php) ):

[![doc/screenshot1.jpg](doc/screenshot1.jpg)](doc/screenshot1.jpg)

Another example ( [examples/test.php](examples/test2.php) ):

[![doc/screenshot2.jpg](doc/screenshot2.jpg)](doc/screenshot2.jpg)

Getting started
---------------

[](#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
-------

[](#classes)

### DashOne

[](#dashone-1)

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 &lt; head &gt; 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](doc/screenshotdashboardempty.jpg)](doc/screenshotdashboardempty.jpg)

#### Method DashOne-&gt;head($title,$extrahtml)

[](#method-dashone-headtitleextrahtml)

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

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

#### Method DashOne-&gt;menuUpper($leftControls=\[\],$rightControls=\[\])

[](#method-dashone-menuupperleftcontrolsrightcontrols)

It renders the upper menu of the dashboard.

> $dash-&gt;menuUpper(\[new ImageOne('')," - ",new LinkOne('Cocacola','#')\]);

### AlertOne

[](#alertone)

It renders an alert

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

Example:

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

[![doc/screenshotalert.jpg](doc/screenshotalert.jpg)](doc/screenshotalert.jpg)

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

[![doc/screenshotalert2.jpg](doc/screenshotalert2.jpg)](doc/screenshotalert2.jpg)

### ButtonOne

[](#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-&gt;buttons($buttons,true)

[![doc/screenshotbutton1.jpg](doc/screenshotbutton1.jpg)](doc/screenshotbutton1.jpg)

> $dash-&gt;buttons($buttons,false)

[![doc/screenshotbutton2.jpg](doc/screenshotbutton2.jpg)](doc/screenshotbutton2.jpg)

### ContainerOne

[](#containerone)

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

> new ContainerOne($html);

Example:

```
	$dash->container("%control")
		->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("%control")->rawHtml("hello world")
```

[![doc/screencontainer.jpg](doc/screencontainer.jpg)](doc/screencontainer.jpg)

### FormOne

[](#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](doc/screenshotform0.jpg)](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](doc/screenshotform.jpg)](doc/screenshotform.jpg)

### UlOne

[](#ulone)

It draws a list (unsorted list)

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

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

[![doc/screenshotul.jpg](doc/screenshotul.jpg)](doc/screenshotul.jpg)

### ImageOne

[](#imageone)

It draws a image

> new ImageOne('');

[![https://via.placeholder.com/32x32](https://camo.githubusercontent.com/c3085faa88a7888a044ed1f20277725a6b1c84eb638036ff403f2803bc84f633/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f3332783332)](https://camo.githubusercontent.com/c3085faa88a7888a044ed1f20277725a6b1c84eb638036ff403f2803bc84f633/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f3332783332)

### LinkOne

[](#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-&gt;link('Cocacola','#','far fa-star')

[![doc/link.jpg](doc/link.jpg)](doc/link.jpg)

### TableOne

[](#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](doc/screenshottable.jpg)](doc/screenshottable.jpg)

### A basic page :

[](#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:

[](#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();
```

### Login Page

[](#login-page)

[examples/testlogin.php](examples/testlogin.php)

[![doc/login.jpg](doc/login.jpg)](doc/login.jpg)

The library has a build-in login page that it relies on PHP's session variable.

To use a the function, the session must be enabled

```
@session_start(); // or via php.ini
```

And we could read the current session as follow:

```
$_SESSION['user'];
// array(5) { ["username"]=> "" ["password"]=> "" ["remember"]=> "" ["_csrf"]=>  "" ["result"]=> bool(true) }
```

#### Step 1 Initialize Login Page

[](#step-1-initialize-login-page)

To create a login page, you must initialize in the constructor as follow

Using an array (user and password)

```
$dash=new DashOne(false,true,'salt_123',['user'=>'john','password'=>'doe']);
```

Or using a method

```
$validateLogin= function($user) {
    // this method could access to the database
    return $user['username'] === 'john' && $user['password'] === 'doe';
};
$dash=new DashOne(false,false,'salt_123',$validateLogin);
```

#### Step 2 Fetch values

[](#step-2-fetch-values)

```
$user=[];
$dash->fetchLogin($user); // user could returns [ ["username"]=> "" ["password"]=> "" ["remember"]=> "" ["_csrf"]=>  "" ["result"]=> bool(true) ]
```

#### Step 3 Redirect if the user has sign-in correctly

[](#step-3-redirect-if-the-user-has-sign-in-correctly)

```
if($user['result']) {
    @session_write_close();
    header('location:testlogin2.php');
    die(1);
} else {
    $message='user or password incorrect';
}
```

#### Step 4 Display Login Screen

[](#step-4-display-login-screen)

```
$dash->head('Example - test 1','',true) // title of the page, extra content in the header and true= for login page
    ->login($user,null,'Sign-In') // user variable, null or link to the login image and title of the login page
        ->alert($message) // (optional) shows an alert inside the login page
        ->footer() // (optional) shows a footer inside the login
    ->endLogin() // end login container
->render();
```

#### Step 5 Log out

[](#step-5-log-out)

The validation of the user is keep in the session. So to close a session we could destroy the session or unsetting the session.

```
session_destroy();
unset($_SESSION['user']);
```

#### Step 6 CSRF protection (optional)

[](#step-6-csrf-protection-optional)

It is possible to add an extra layer of protection by adding the next line

```
if (!$dash->checkCSRF()) {
    die(1);
}
```

#### Step 7 Validating the session

[](#step-7-validating-the-session)

It is possible to validate the session

```
if (isset($_SESSION['user']) ) {
	// user has sign-in
} else {
    // user hasn't sign-in
}
```

Version
-------

[](#version)

- 1.7 2020-04-23
    - Added .gitattribute Examples and doc are not pushed via composer (it should reduce the size)
- 1.6.2 2020-04-23
    - Fix: cleanups.
- 1.6.1 2020-03-03
    - Fix: TableOne now allows non-base zero array
- 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)

Copyright Jorge Patricio Castro Castillo 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.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~45 days

Recently: every ~24 days

Total

10

Last Release

2213d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8bf6ba9d7f6f6c3ecde2779a29e1a4948f0f338c074ddceb3fbeb79c6dd1e68c?d=identicon)[JorgeCastro](/maintainers/JorgeCastro)

---

Top Contributors

[![jorgecc](https://avatars.githubusercontent.com/u/9570242?v=4)](https://github.com/jorgecc "jorgecc (26 commits)")

---

Tags

dashboardphpphp7phpbladetemplatetemplatingview

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eftec-dashone/health.svg)

```
[![Health](https://phpackages.com/badges/eftec-dashone/health.svg)](https://phpackages.com/packages/eftec-dashone)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8208.4M87](/packages/eftec-bladeone)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1018.1k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
