Download the PHP package tobento/service-table without Composer
On this page you can find all versions of the php package tobento/service-table. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/service-table
More information about tobento/service-table
Files in tobento/service-table
Package service-table
Short Description Building HTML tables easily.
License MIT
Homepage https://www.tobento.ch
Informations about the package service-table
Table Service
The Table Service provides a way for building tables easily.
Table of Contents
- Getting started
- Requirements
- Highlights
- Screenshots
- Simple Example
- Documentation
- Create Table
- Create Rows
- Create Row
- Row Methods
- Custom Row
- Table Attributes
- Render Table
- Default Renderer
- Table Renderer
- Custom Renderer
- Credits
Getting started
Add the latest version of the Table service project running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
- Customize rendering
Screenshots
Simple Example
Render the table
Both tables from above will produce the following output
Documentation
Create Table
With Methods
You might change some data or implentation by the following "with methods" returning a new instance.
withColumns
withRenderer
Create Rows
Creating rows from array items
Using a callback for creating rows
You may use a callback for creating rows if you provide an array of objects for instance or want to create only specific row columns.
Create only specific row columns from an array of items:
Create Row
Creating a row from an array
Using a callback for creating row columns
You may use a callback for creating row columns if you provide an object.
Row Methods
Heading
You may mark the row as a heading.
Id
You may give the row an id to fetch it later.
Each
You may use the each method to create the row columns.
When
The when method will execute the given callback when the first argument given to the method evaluates to true.
Html
You may mark columns as html, indicating that no escaping is done.
PependHtml / AppendHtml
You may prepend and append html to the row.
Column
You may use the column method to add a column.
Custom Row
You may use the addRow method to pass a custom row.
Table Attributes
You may set table attributes which will be rendered depending on the renderer.
Render Table
There are different ways of rendering the table depending on your needs.
Default Renderer
The default renderer generates the table using elements and calculates the columns size automatically.
Outputs:
Table Renderer
The table renderer generates the table using the HTML element.
Outputs:
The and methods will be ignored as it would produce invalid HTML!
Custom Renderer
You might write your own renderer fitting your application.
Credits
- Tobias Strub
- All Contributors