adilab / html
Adi HTML Tools for PHP
v1.0.0
2016-04-16 19:12 UTC
Requires
- adilab/core: *
- adilab/css: *
This package is not auto-updated.
Last update: 2024-12-13 20:24:12 UTC
README
Adi HTML Tools for PHP is a set of class for prepare HTML code directly in PHP. The set content class for work with basic HTML tags, and to create HTML table code taking data from an array.
Installing
Preferred way to install is with Composer.
Install this library using composer:
$ composer require adilab/html
Usage:
Usage of Tag class. Online demo.
require('vendor/autoload.php'); use Adi\Html\Tag; $p = new Tag('p', 'Hello world'); $p->addStyle('color: #ff0000')->addStyle('background-color', '#ccc'); echo $p->render();
Usage of complex HTML structure. Online demo.
require('vendor/autoload.php'); use Adi\Html\Div; use Adi\Html\Strong; echo Div::create(Strong::create('Hello world'))->setStyle('color: #ff0000');
Usage of Table class. Online demo.
require('vendor/autoload.php'); use Adi\Html\Table\Table; use Adi\Html\Table\Tr; use Adi\Html\Table\Td; $data = array( array('aaa', 'bbb', Td::create('ccc')->addClass('ccc')), array('ddd', 'eee', 'fff'), Tr::create(array('ggg', 'hhh', 'iii'))->addClass('selected'), ); echo Table::create($data);
Usage of Table class - named columns. Online demo.
require('vendor/autoload.php'); use Adi\Html\Table\Table; use Adi\Html\Table\Th; use Adi\Html\Table\Tr; use Adi\Html\Table\Column; use Adi\Html\Table\Td; $data = array( array('A' => 'aaa', 'B' => 'bbb', 'C' => 'ccc'), array('A' => 'ddd', 'B' => 'eee', 'C' => 'fff'), array('A' => 'ggg', 'B' => 'hhh', 'C' => Td::create('iii')->setId('i')), ); $table = new Table($data); $table->setColumn('B', Column::create()->addStyle('color', '#ff0000')); $table->setHeader('B', '[B]'); $table->setHeader('C', Th::create('[C]')->addStyle('color', '#0000ff')); echo $table;