https://github.com/lib16/html-builder-php
lib16 RSS Builder is a PHP 8 library for creating HTML5 documents.
https://github.com/lib16/html-builder-php
builder html html5 php php8 table writer
Last synced: about 1 month ago
JSON representation
lib16 RSS Builder is a PHP 8 library for creating HTML5 documents.
- Host: GitHub
- URL: https://github.com/lib16/html-builder-php
- Owner: lib16
- License: mit
- Created: 2020-12-27T17:10:54.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-01T17:58:16.000Z (over 5 years ago)
- Last Synced: 2025-03-20T12:38:32.059Z (about 1 year ago)
- Topics: builder, html, html5, php, php8, table, writer
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lib16 HTML Builder for PHP 8
A library for creating HTML5 written in PHP 8.
[](https://travis-ci.com/lib16/html-builder-php)
[](https://codecov.io/gh/lib16/html-builder-php)
## Installation with Composer
This package is available on [packagist](https://packagist.org/packages/lib16/html),
therefore you can use [Composer](https://getcomposer.org) to install it.
Run the following command in your shell:
```
composer require lib16/html dev-main
```
## Basic Usage
Build your tables with this library:
``` php
'Panther', 'city' => 'Berlin', 'quantity/store' => 20],
['model' => 'Panther', 'city' => 'Berlin', 'quantity/store' => 12],
['model' => 'Panther', 'city' => 'Cologne', 'quantity/store' => 12],
['model' => 'Lion', 'city' => 'Cologne', 'quantity/store' => 12],
['model' => 'Lion', 'city' => 'Hamburg', 'quantity/store' => 15],
['model' => 'Lion', 'city' => 'Hamburg', 'quantity/store' => 15],
['model' => 'Lion', 'city' => 'Munich', 'quantity/store' => 15],
];
$table = Table::create('Availability')->setClass('t1');
$table->thead()->tr()->thn('model', 'city', 'quantity/store');
$table->bodies($data);
print $table;
// change order
$keys = ['city', 'model', 'quantity/store'];
$table = Table::create('Availability')->setClass('t1');
$table->thead()->tr()->headerCells($keys);
$table->bodies($data, ...$keys);
print $table;
// row by row
$table = Table::create('Availability')->setClass('t2');
$table->thead()->tr()->thn('model', 'city', 'quantity/store');
foreach ($data as $row) {
$table->tr()->dataCells($row);
}
print $table;
?>
body, * {
font-family: source serif pro, serif;
}
caption, th {
font-family: source sans pro, sans-serif;
}
caption {
margin: 0.5em;
}
td, th {
text-align: left;
vertical-align: text-top;
padding: 0.5em;
border: 1px solid rgb(0, 51, 102);
}
td:last-child {
text-align: right;
}
th {
color: white;
background-color: rgba(0, 51, 102, 1);
font-weight: normal;
}
.t1 tbody,
.t2 tr {
background-color: rgba(51, 102, 0, 0.2);
}
.t1 tbody:nth-child(2n),
.t2 tr:nth-child(2n) {
background-color: rgba(52, 102, 0, 0.3);
}
table {
border-collapse: collapse;
margin: 2em;
float: left;
}
```