{"id":15578482,"url":"https://github.com/eftec/dashone","last_synced_at":"2025-04-24T02:22:21.321Z","repository":{"id":56975546,"uuid":"175509332","full_name":"EFTEC/DashOne","owner":"EFTEC","description":"It is a library","archived":false,"fork":false,"pushed_at":"2020-04-23T13:09:09.000Z","size":226,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T10:23:23.762Z","etag":null,"topics":["dashboard","php","php7"],"latest_commit_sha":null,"homepage":"https://www.eftec.cl","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EFTEC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-13T22:37:47.000Z","updated_at":"2025-01-04T02:14:54.000Z","dependencies_parsed_at":"2022-08-21T12:20:13.011Z","dependency_job_id":null,"html_url":"https://github.com/EFTEC/DashOne","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FDashOne","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FDashOne/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FDashOne/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EFTEC%2FDashOne/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EFTEC","download_url":"https://codeload.github.com/EFTEC/DashOne/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546395,"owners_count":21448322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dashboard","php","php7"],"created_at":"2024-10-02T19:10:46.436Z","updated_at":"2025-04-24T02:22:21.300Z","avatar_url":"https://github.com/EFTEC.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DashOne\nA minimalist dashboard /backend library  for PHP\n\nThis 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) )\n\n[![Build Status](https://travis-ci.org/EFTEC/DashOne.svg?branch=master)](https://travis-ci.org/EFTEC/DashOne)\n[![Packagist](https://img.shields.io/packagist/v/eftec/dashone.svg)](https://packagist.org/packages/eftec/dashone)\n[![Total Downloads](https://poser.pugx.org/eftec/dashone/downloads)](https://packagist.org/packages/eftec/dashone)\n[![Maintenance](https://img.shields.io/maintenance/yes/2020.svg)]()\n[![composer](https://img.shields.io/badge/composer-%3E1.6-blue.svg)]()\n[![php](https://img.shields.io/badge/php-\u003e5.6-green.svg)]()\n[![php](https://img.shields.io/badge/php-7.x-green.svg)]()\n[![CocoaPods](https://img.shields.io/badge/docs-70%25-yellow.svg)]()\n\n\nExample  ( [examples/test.php](examples/test2.php) ):\n\n![doc/screenshot1.jpg](doc/screenshot1.jpg)\n\n\nAnother example ( [examples/test.php](examples/test2.php) ):\n\n![doc/screenshot2.jpg](doc/screenshot2.jpg)\n\n## Getting started\n\nInstall via composer \n\n\u003e composer require eftec/dashone\n\nCreate a new object DashOne (you will need to add the required include, via autoload.php or manually)\n\n\u003e $dash=new DashOne();\n\nAnd you could render a page using the object of the class DashOne()\n\n```php\nuse eftec\\DashOne\\DashOne;\n$dash=new DashOne();\n$dash-\u003ehead('Example - test 1'); // it is required\n$dash-\u003erawHtml('hello world'); \n$dash-\u003efooter(); // it is required\n$dash-\u003erender(); // it renders an empty page\n```\n\n## Classes\n\n### DashOne\n\nIt is the main class that generates the dashboard.\n\n\u003e $dash=new DashOne();\n\nIt is possible to add new elements using fluent interface (chain methods each one).\n\n\nExample: It renders an empty page\n\n```php\nuse eftec\\DashOne\\DashOne;\n$dash=new DashOne();\n\n$dash-\u003ehead('Example - test 1');\n$dash-\u003efooter();\n$dash-\u003erender();\n```\n\nExample using fluent\n\n```php\nuse eftec\\DashOne\\DashOne;\n$dash=new DashOne();\n$dash-\u003ehead('Example - test 1')\n    -\u003efooter()\n    -\u003erender();\n```\n\nWhere the method head is required to render the \u003c head \u003e of the page.\n\nThe footer is also required to close all the tags.\n\nAnd every chain of methods must end with the method render() (it draw the page).\n\n```php\n// see examples/testuibasic.php\n$dash=new DashOne();\n$dash-\u003ehead('Example - test 1')\n\t-\u003emenuUpper(['Upper title'])\n\t-\u003estartcontent()\n\t-\u003emenu($links) // left menu\n\t-\u003estartmain()\n\t// here it goes the content\n\t-\u003eendmain()\n\t-\u003eendcontent()\n\t-\u003efooter()\n\t-\u003erender();\t\t\n```\n![doc/screenshotdashboardempty.jpg](doc/screenshotdashboardempty.jpg)\n\n\n#### Method DashOne-\u003ehead($title,$extrahtml)\n\nIt renders the head of the page.  This element is required\n\n\u003e $dash-\u003ehead('Example - test 1');\n\n#### Method DashOne-\u003emenuUpper($leftControls=[],$rightControls=[])\n\nIt renders the upper menu of the dashboard.\n\n\u003e $dash-\u003emenuUpper([new ImageOne('https://via.placeholder.com/32x32'),\" - \",new LinkOne('Cocacola','#')]);\n\n\n\n\n### AlertOne\n\nIt renders an alert\n\n\u003e new AlertOne($title,$content,$class);\n\nExample:\n\n```php\n$dash-\u003ealert(\"It is an alert\",\"Content of the alert\")\n\n```\n\n![doc/screenshotalert.jpg](doc/screenshotalert.jpg)\n\n```php\n$dash-\u003ealert(\"It is an alert\",\"Content of the alert\",\"alert alert-danger\")\n```\n\n![doc/screenshotalert2.jpg](doc/screenshotalert2.jpg)\n\n### ButtonOne\n\nIt renders a button\n\n\u003e new ButtonOne('button1','Click me','btn btn-primary');\n\nYou 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.\n\n```php\n\n$buttons=[\n\tnew ButtonOne('button1','Click me','btn btn-primary'),\n\tnew ButtonOne('button2','Click me too','btn btn-danger')\n];\n\n\n$dash-\u003ebuttons($buttons,false) // where if true then buttons are aligned with the form\n\n```\n\n\u003e $dash-\u003ebuttons($buttons,true) \n\n![doc/screenshotbutton1.jpg](doc/screenshotbutton1.jpg)\n\n\u003e $dash-\u003ebuttons($buttons,false)\n\n![doc/screenshotbutton2.jpg](doc/screenshotbutton2.jpg)\n\n\n### ContainerOne\n\nIt renders a container where it is possible to add other elements (such as buttons)\n\n\u003e new ContainerOne($html);\n\nExample:\n\n```php\n\t$dash-\u003econtainer(\"\u003cdiv class='form-group row'\u003e\u003cdiv class='col-sm-10 offset-sm-2'\u003e%control\u003c/div\u003e\u003c/div\u003e\")\n\t\t-\u003ebuttons($buttons)\n```\nThe method container() but be followed by a visual method. This method is added inside the container (where it says %control)\n\nAnother example:\n\n```php\n\t$dash-\u003econtainer(\"\u003chr\u003e%control\u003chr\u003e\")-\u003erawHtml(\"hello world\")\n```\n\n![doc/screencontainer.jpg](doc/screencontainer.jpg)\n\n\n\n### FormOne\n\nIt renders a form. It requires a declarative array.\n\nIf it sets a definition, then it uses the definition to define the types of input objects (textbox,textarea,etc.)\n\nIf a field of the definition has an array then it is used to render a dropdownitem\n\nIf it doesn't have a definition then, it uses the values to define the types of input objects (textboxes,textareas,etc.)\n\n\n\nYou could also render a message (for example for warning or information)\nYou could draw a form using an associative array. By default, every field will be a textbox\n\n```php\n$currentValue=['IdProduct'=\u003e\"2\"\n\t,'Name'=\u003e\"aaa\"\n\t,'Price'=\u003e\"333\"\n\t,'Type'=\u003e1\n\t,'Description'=\u003e''];\n\n$dash-\u003eform($currentValue) // it's macro of new FormOne()\n```\n\n![doc/screenshotform0.jpg](doc/screenshotform0.jpg)\n\nOr you could explicit the type of field\n\n```php\n$definition=['IdProduct'=\u003e'hidden'\n\t,'Name'=\u003e'text'\n\t,'Price'=\u003e'text'\n\t,'Type'=\u003e['cocacola','fanta','sprite']\n\t,'Description'=\u003e'textarea'];\n$currentValue=['IdProduct'=\u003e\"2\"\n\t,'Name'=\u003e\"aaa\"\n\t,'Price'=\u003e\"333\"\n\t,'Type'=\u003e1\n\t,'Description'=\u003e''];\n\n$dash-\u003eform($currentValue,$definition) // it's macro of new FormOne()\n```\n\n![doc/screenshotform.jpg](doc/screenshotform.jpg)\n\n### UlOne\n\nIt draws a list (unsorted list)\n\n```php\n$valueUL=['Cocacola','Fanta','Sprite'];\n\n$dash-\u003eul($valueUL) // it's macro of new UlOne()\n```\n\n![doc/screenshotul.jpg](doc/screenshotul.jpg)\n\n### ImageOne\n\nIt draws a image\n\n\u003e new ImageOne('https://via.placeholder.com/32x32');\n\n![https://via.placeholder.com/32x32](https://via.placeholder.com/32x32)\n\n### LinkOne\n\nIt draws a hyperlink\n\nThe 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)\n\n\u003e new LinkOne('Cocacola','#','far fa-star')\n\u003e $dash-\u003elink('Cocacola','#','far fa-star')\n\n![doc/link.jpg](doc/link.jpg)\n\n\n\n### TableOne\n\nit renders a table.\n\n```php\n$values=\n\t[\n\t\t['IdProduct'=\u003e1,'Name'=\u003e'Cocacola','Price'=\u003e\"20.2\"],\n\t\t['IdProduct'=\u003e2,'Name'=\u003e'Fanta','Price'=\u003e\"30.5\"],\n\t\t['IdProduct'=\u003e3,'Name'=\u003e'Sprite','Price'=\u003e\"11.5\"],\n\t];\n\n$dash-\u003etable($values)-\u003e...  // it must be called after the render\n```\n\n![doc/screenshottable.jpg](doc/screenshottable.jpg)\n\n\n\n\n### A basic page :\n\nAny pages requires at least to call the head(), footer() and Render().\n\nRender() draws the page so it must be called at the end of the chain.\n\nFor example, a basic page is as follow:\n\n\n```php\n$dash=new DashOne();\n\n$dash-\u003ehead('Example - test 1');\n$dash-\u003efooter();\n$dash-\u003erender();\n```\n\n### An empty dashboard:\n\n\n```php\n$dash=new DashOne();\n\n$dash-\u003ehead('Example - test 1');\n$dash-\u003emenuUpper([new ImageOne('https://via.placeholder.com/32x32'),\" - \",new LinkOne('Cocacola','#')]);\n$dash\n\t-\u003estartcontent() // start the container\n\t\t-\u003emenu($links) // left menu\n\t\t-\u003estartmain() // start the main container\n\t\t\t-\u003etitle('Table of Products')\n\t\t-\u003eendmain()\n\t-\u003eendcontent();\n$dash-\u003efooter();\n$dash-\u003erender();\n```\n\n### Login Page\n\n[examples/testlogin.php](examples/testlogin.php)\n\n![doc/login.jpg](doc/login.jpg)\n\nThe library has a build-in login page that it relies on PHP's session variable.\n\nTo use a the function, the session must be enabled\n\n```php\n@session_start(); // or via php.ini\n```\n\nAnd we could read the current session as follow:\n\n```php\n$_SESSION['user'];\n// array(5) { [\"username\"]=\u003e \"\" [\"password\"]=\u003e \"\" [\"remember\"]=\u003e \"\" [\"_csrf\"]=\u003e  \"\" [\"result\"]=\u003e bool(true) }\n```\n\n\n\n#### Step 1 Initialize Login Page\n\nTo create a login page, you must initialize in the constructor as follow\n\nUsing an array (user and password)\n\n```php\n$dash=new DashOne(false,true,'salt_123',['user'=\u003e'john','password'=\u003e'doe']);\n```\n\nOr using a method\n\n```php\n$validateLogin= function($user) {\n    // this method could access to the database\n    return $user['username'] === 'john' \u0026\u0026 $user['password'] === 'doe';\n};\n$dash=new DashOne(false,false,'salt_123',$validateLogin);\n```\n\n#### Step 2 Fetch values\n\n```php\n$user=[];\n$dash-\u003efetchLogin($user); // user could returns [ [\"username\"]=\u003e \"\" [\"password\"]=\u003e \"\" [\"remember\"]=\u003e \"\" [\"_csrf\"]=\u003e  \"\" [\"result\"]=\u003e bool(true) ]\n```\n\n#### Step 3 Redirect if the user has sign-in correctly\n\n```php\nif($user['result']) {\n    @session_write_close();\n    header('location:testlogin2.php');\n    die(1);\n} else {\n    $message='user or password incorrect';\n}\n```\n\n#### Step 4 Display Login Screen\n\n```php\n$dash-\u003ehead('Example - test 1','',true) // title of the page, extra content in the header and true= for login page\n    -\u003elogin($user,null,'Sign-In') // user variable, null or link to the login image and title of the login page\n        -\u003ealert($message) // (optional) shows an alert inside the login page\n        -\u003efooter() // (optional) shows a footer inside the login\n    -\u003eendLogin() // end login container\n-\u003erender();\n```\n\n#### Step 5 Log out\n\nThe validation of the user is keep in the session. So to close a session we could destroy the session or unsetting the session.\n\n```php\nsession_destroy();\nunset($_SESSION['user']);\n```\n\n#### Step 6 CSRF protection (optional)\n\nIt is possible to add an extra layer of protection by adding the next line\n\n```php\nif (!$dash-\u003echeckCSRF()) {\n    die(1);\n}\n```\n\n#### Step 7 Validating the session\n\nIt is possible to validate the session \n\n```php\nif (isset($_SESSION['user']) ) {\n\t// user has sign-in\n} else {\n    // user hasn't sign-in\n}\n```\n\n\n\n## Version\n\n* 1.7 2020-04-23\n    * Added .gitattribute Examples and doc are not pushed via composer (it should reduce the size)\n* 1.6.2 2020-04-23   \n    * Fix: cleanups.   \n* 1.6.1 2020-03-03\n    * Fix: TableOne now allows non-base zero array\n* 1.6 2020-18-01\n    * modified LinkOne::LinkOne()\n    * added summernote to textarea\n* 1.5 2020-16-01\n    * new method getLogin()\n    * new method logout()\n* 1.4 2020-16-01 \n    * new method cssLogin()\n    * new method login()\n    * new method fetchLogin()\n    * new method decrypt()\n    * new method encrypt()      \n    * new field var $salt='';\n    * new field $validateLogin (callable)\n    * changes to __construct()\n* 1.3 2020-01-15 new method fetchvalue()\n* 1.2 2019-03-30 New changes.  \n* 1.1 2019-03-17 Fixed some bugs  \n* 1.0 2019-03-01 First Version.  \n\n\n## Copyright\n\nCopyright Jorge Patricio Castro Castillo \u003cjcastro arroba eftec dot cl\u003e\nDual License (LGPL v3 and Commercial License)  \n\nYou could use in commercial / close source product or service while  \n\nIn a nutshell (it is the license): \n\n* You must keep the copyright notices.  \n* If you modify the library then you must share the changes and modifications.\n\n   \n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fdashone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feftec%2Fdashone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feftec%2Fdashone/lists"}