PHPackages                             jdz/table - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jdz/table

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jdz/table
=========

A simple PHP Table generation library.

1.0.1(4mo ago)03MITPHPPHP &gt;=8.2

Since Jan 6Pushed 4mo agoCompare

[ Source](https://github.com/joffreydemetz/table)[ Packagist](https://packagist.org/packages/jdz/table)[ Docs](https://jdz.joffreydemetz.com/table/)[ RSS](/packages/jdz-table/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

JDZ Table
=========

[](#jdz-table)

A simple PHP library for generating HTML tables with ease.

Features
--------

[](#features)

- 🎯 Simple and intuitive API
- 🎨 Support for custom styles and attributes
- 📊 Column width management
- 🔗 Colspan support
- 🔄 Fluent interface for method chaining

Requirements
------------

[](#requirements)

- PHP 8.2 or higher

Installation
------------

[](#installation)

Install via Composer:

```
composer require jdz/table
```

Quick Start
-----------

[](#quick-start)

```
use JDZ\Table\Table;

// Create a table with headers
$table = new Table(['Name', 'Age', 'City']);

// Add rows
$table->addRow(['John Doe', '30', 'New York'])
      ->addRow(['Jane Smith', '25', 'Los Angeles']);

// Render the table
echo $table->render();
```

Output:

```

   Name
   Age
   City

   John Doe
   30
   New York

   Jane Smith
   25
   Los Angeles

```

Usage
-----

[](#usage)

### Creating a Table

[](#creating-a-table)

#### With String Headers

[](#with-string-headers)

```
$table = new Table(['Column 1', 'Column 2', 'Column 3']);
```

#### With Custom Header Objects

[](#with-custom-header-objects)

```
use JDZ\Table\Th;

$header1 = new Th('Name');
$header1->setStyle('color', 'blue');

$table = new Table([$header1, 'Age', 'Email']);
```

### Adding Rows

[](#adding-rows)

#### Simple String Values

[](#simple-string-values)

```
$table->addRow(['Alice', '28', 'alice@example.com']);
```

#### With Custom Cell Objects

[](#with-custom-cell-objects)

```
use JDZ\Table\Td;

$cell = new Td('Important');
$cell->setStyle('color', 'red')
     ->setAttribute('class', 'highlight');

$table->addRow([$cell, 'Data', 'More data']);
```

### Setting Column Widths

[](#setting-column-widths)

```
$table->setColumnWidth(0, 50)  // First column: 50%
      ->setColumnWidth(1, 25)  // Second column: 25%
      ->setColumnWidth(2, 25); // Third column: 25%
```

### Using Colspan

[](#using-colspan)

```
use JDZ\Table\Td;

$spanningCell = new Td('This spans 2 columns', 2);
$table->addRow([$spanningCell, 'Normal cell']);
```

### Styling Cells

[](#styling-cells)

#### Adding CSS Classes

[](#adding-css-classes)

```
$cell = new Td('Content');
$cell->setAttribute('class', 'my-class');
```

#### Adding Inline Styles

[](#adding-inline-styles)

```
$cell = new Td('Content');
$cell->setStyle('color', 'red')
     ->setStyle('font-weight', 'bold')
     ->setStyle('background-color', '#ffff99');
```

#### Adding Multiple Attributes

[](#adding-multiple-attributes)

```
$cell = new Td('Content');
$cell->setAttribute('class', 'highlight')
     ->setAttribute('id', 'cell-1')
     ->setAttribute('data-value', '123');
```

### Custom Headers

[](#custom-headers)

```
use JDZ\Table\Th;

$header = new Th('Status');
$header->setWidth(20)  // 20% width
       ->setStyle('color', 'blue')
       ->setAttribute('class', 'header-cell');
```

Complete Example
----------------

[](#complete-example)

```
use JDZ\Table\Table;
use JDZ\Table\Td;

// Create table with headers
$table = new Table(['Product', 'Price', 'Stock']);

// Set column widths
$table->setColumnWidth(0, 50)
      ->setColumnWidth(1, 25)
      ->setColumnWidth(2, 25);

// Add rows with styled cells
$priceCell = new Td('$999');
$priceCell->setStyle('color', 'green')
          ->setStyle('font-weight', 'bold');

$stockCell = new Td('Low');
$stockCell->setStyle('color', 'red');

$table->addRow(['Laptop', $priceCell, $stockCell]);
$table->addRow(['Mouse', '$29', '150']);

// Render
echo $table;  // Uses __toString() magic method
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with detailed output:

```
vendor/bin/phpunit --testdox
```

Run tests with code coverage:

```
vendor/bin/phpunit --coverage-text
```

Examples
--------

[](#examples)

See the [examples](examples/) directory for more usage examples:

License
-------

[](#license)

This library is licensed under the MIT License. See [LICENSE](LICENSE) file for details.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance76

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e83e3701566e43438525ed14578487e732b849d152b5071aa1613a0dad96913?d=identicon)[jdz](/maintainers/jdz)

---

Top Contributors

[![joffreydemetz](https://avatars.githubusercontent.com/u/15113527?v=4)](https://github.com/joffreydemetz "joffreydemetz (8 commits)")

---

Tags

tableJDZ

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdz-table/health.svg)

```
[![Health](https://phpackages.com/badges/jdz-table/health.svg)](https://phpackages.com/packages/jdz-table)
```

###  Alternatives

[wenzhixin/bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)

11.8k283.4k1](/packages/wenzhixin-bootstrap-table)[mottie/tablesorter

tablesorter (FORK) is a jQuery plugin for turning a standard HTML table with THEAD and TBODY tags into a sortable table without page refreshes. tablesorter can successfully parse and sort many types of data including linked data in a cell.

2.6k223.5k](/packages/mottie-tablesorter)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)[datatables.net/datatables.net

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. This is jQuery DataTables

56156.5k25](/packages/datatablesnet-datatablesnet)[gbrock/laravel-table

Table functionality for Laravel models

7644.3k](/packages/gbrock-laravel-table)[fedemotta/yii2-widget-datatables

DataTables widget for Yii2

34179.4k1](/packages/fedemotta-yii2-widget-datatables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
