Download the PHP package ucscode/table-generator without Composer
On this page you can find all versions of the php package ucscode/table-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ucscode/table-generator
More information about ucscode/table-generator
Files in ucscode/table-generator
Package table-generator
Short Description Lightweight PHP library that simplifies the process of creating tables with minimal code
License MIT
Informations about the package table-generator
Table Generator
Table Generator is a powerful yet flexible PHP library that allows you to create and manipulate HTML tables dynamically with minimal effort. Whether you need to generate tables from MySQL query results, CSV data, associative arrays, or any custom format, this package provides a structured and extensible way to do so.
Features
- Adapter System — Convert various data structures (MySQL result, CSV, JSON, Doctrine, etc.) into tables.
- Pagination Support — Easily paginate large datasets using ucscode/easy-paginator.
- Middleware Customization — Modify table rows dynamically (e.g., add action buttons, hide sensitive data).
- Modular Components — Each table element (thead, tbody, tr, td, etc.) is an instance, allowing for full customization.
- Meta — Store temporary values without exposing them in HTML.
- DOM Manipulation with UssElement — Directly set attributes, classes, or IDs on table elements.
Installation
Install via Composer:
Quick Example
Table of Contents
- Adapters
- Pagination
- Middleware
- Table Components
- Meta
- Customization
- Interactive Example
Adapters
Adapters are responsible for structuring data into an HTML table. Each adapter converts a specific data format into table rows and columns.
Available Adapters
- CsvArrayAdapter — Converts a 2D array (CSV-like data) into a table.
- AssocArrayAdapter — Uses associative arrays where the keys become the table headers.
- MysqliResultAdapter — Transforms a MySQLi result object into a table.
Example: Using a MySQLi Adapter
Pagination
Pagination is integrated using ucscode/easy-paginator which allows only a subset of table rows is displayed per page.
Example: Paginating a CSV Table
Middleware
Middleware allows modification of table rows before rendering. This is useful when data sources cannot be directly modified (e.g., MySQL results).
Example: Adding an "Actions" Column
Apply middleware when creating the table:
Alternatively, apply middleware and regenerate the table structure
Table Components
Each part of the table (thead, tbody, tr, td, etc.) is an instance, allowing manipulation before rendering.
Meta
The Meta
instance store metadata that neither affects table rendering nor appear in the HTML output.
Customization
Custom adapters can be created by implementing AdapterInterface
:
For more details, see the full documentation.
License
This package is licensed under the MIT License.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
If the project was helpful to you, please add a star