PHPackages                             warslett/table-builder - 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. [Database &amp; ORM](/categories/database)
4. /
5. warslett/table-builder

ActiveLibrary[Database &amp; ORM](/categories/database)

warslett/table-builder
======================

table abstraction, table building, table rendering

0.2.2(4y ago)521.1k↓13.5%21MITPHP

Since Dec 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/warslett/table-builder)[ Packagist](https://packagist.org/packages/warslett/table-builder)[ RSS](/packages/warslett-table-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (14)Versions (6)Used By (1)

Table Builder
=============

[](#table-builder)

[![Latest Stable Version](https://camo.githubusercontent.com/506037dfec4f0e8cddb79c79479bc27754cc25cf70a10b0fd7bcf272b70c3a65/68747470733a2f2f706f7365722e707567782e6f72672f776172736c6574742f7461626c652d6275696c6465722f76)](//packagist.org/packages/warslett/table-builder)[![Build Status](https://camo.githubusercontent.com/cca7a57ca8fd13e689ae381481ed8241fc8c73368ca820c1413b74eca0956799/68747470733a2f2f636972636c6563692e636f6d2f67682f776172736c6574742f7461626c652d6275696c6465722e706e673f7374796c653d736869656c64)](https://circleci.com/gh/warslett/table-builder)[![codecov](https://camo.githubusercontent.com/7e20ff73e335d9d6367ce0df33e41a3ba3deea4a1ff02ec02641c75b6f64aed9/68747470733a2f2f636f6465636f762e696f2f67682f776172736c6574742f7461626c652d6275696c6465722f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d544c505548544d503245)](https://codecov.io/gh/warslett/table-builder)[![Mutation testing badge](https://camo.githubusercontent.com/5011d64ef40ced7cd833e4045ee937da974e34e06f94210a114bac1c2511b359/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246776172736c6574742532467461626c652d6275696c6465722532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/warslett/table-builder/master)[![Psalm coverage](https://camo.githubusercontent.com/a964021651bb87f8a4ff6bbdb069eae62545a1b5efb1ccfd5bafc58eded336d4/68747470733a2f2f73686570686572642e6465762f6769746875622f776172736c6574742f7461626c652d6275696c6465722f636f7665726167652e737667)](https://camo.githubusercontent.com/a964021651bb87f8a4ff6bbdb069eae62545a1b5efb1ccfd5bafc58eded336d4/68747470733a2f2f73686570686572642e6465762f6769746875622f776172736c6574742f7461626c652d6275696c6465722f636f7665726167652e737667)[![Total Downloads](https://camo.githubusercontent.com/5a7eec2a375676384a98f0ef9d4d7607b5bfefd314c945daeb1c620f770cc4cc/68747470733a2f2f706f7365722e707567782e6f72672f776172736c6574742f7461626c652d6275696c6465722f646f776e6c6f616473)](//packagist.org/packages/warslett/table-builder)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

Table builder provides table abstraction, table building and table rendering. Allowing you to configure your tables, load your data into them and then render them in a variety of ways. The package can help you implement functionality common to most table actions in CRUD applications including pagination, sorting, row actions, conditional formatting, and exporting the table to csv.

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

[](#installation)

`composer require warslett/table-builder`

If you are using symfony there is an optional bundle that will configure the services:

`composer require warslett/table-builder-bundle warslett/table-builder`

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

[](#requirements)

PHP 7.4, 8.0 or 8.1.

Documentation
-------------

[](#documentation)

Full documentation available [here](https://github.com/warslett/table-builder/blob/master/docs/en/index.md).

Overview
--------

[](#overview)

### Table Building

[](#table-building)

Configure your tables using a variety of column types or implement your own column types. Then load data into the table using one of our data adapters or implement your own. Handle a request to apply sorting and pagination using one of our request adapters or implement your own.

```
// Configure the table structure with a range of out the box column types
$tableBuilder = $this->tableBuilderFactory->createTableBuilder()
    ->rowsPerPageOptions([10, 20, 50])
    ->defaultRowsPerPage(10)
    ->add(TextColumn::withProperty('email')
        ->sortable())
    ->add(DateTimeColumn::withProperty('last_login')
        ->format('Y-m-d H:i:s')
        ->sortable())
    ->add(ActionGroupColumn::withName('actions')
        ->add(ActionBuilder::withName('update')
            ->route('user_update', ['id' => 'id'])) // map 'id' parameter to property path 'id'
        ->add(ActionBuilder::withName('delete')
            ->route('user_delete', ['id' => 'id'])
            ->attribute('extra_classes', ['btn-danger'])));

// Build the table object
$table = $tableBuilder->buildTable('users');

// Configure how data will be loaded into the table
$queryBuilder = $this->entityManager->createQueryBuilder()
    ->select('u')
    ->from(User::class, 'u');

$dataAdapter = DoctrineOrmAdapter::withQueryBuilder($queryBuilder)
    ->mapSortToggle('email', 'u.email')
    ->mapSortToggle('last_login', 'u.lastLogin');

$table->setDataAdapter($dataAdapter);

// Uses parameters on the request to load data into the table with sorting and pagination
$table->handleSymfonyRequest($request);

// OR with a Psr7 Request
$table->handlePsr7Request($request);
```

### Table Rendering

[](#table-rendering)

Modeling tables in an abstract way allows us to provide a variety of generic renderers for rendering them.

For example, with the TwigRendererExtension registered you can render the table in a twig template like this:

```

    {{ table(table) }}

```

Or if you aren't using twig you can use the PhtmlRenderer which uses plain old php templates and has 0 third party dependencies:

```
use WArslett\TableBuilder\Renderer\Html\PhtmlRenderer;

$renderer = new PhtmlRenderer();
echo $renderer->renderTable($table);
```

Both of the above renderers are themeable and are available with a standard theme and bootstrap4 theme out the box.

[![rendered table](https://github.com/warslett/table-builder/raw/master/docs/img/example.png "Rendered Html Table")](https://github.com/warslett/table-builder/raw/master/docs/img/example.png)

You can also render tables as CSV documents:

```
use League\Csv\Writer;
use WArslett\TableBuilder\Renderer\Csv\CsvRenderer;

$csvRenderer = new CsvRenderer();
$csvRenderer->renderTable($table, Writer::createFromPath('/tmp/mycsv.csv'));
```

### Single Page Applications

[](#single-page-applications)

Tables also implement JsonSerializable so they can be encoded as json in a response and consumed by a single page application.

```
// GET /users/table
return new JsonResponse($table);
```

Dependencies
----------------------------------------------------

[](#dependencies)

Table builder has minimal core dependencies however some optional features have additional dependencies.

- CsvRenderer and related classes depends on `league/csv`
- TwigRenderer and related classes depends on `twig/twig`
- DoctrineORMAdapter data adapter depends on `doctrine/orm`
- SymfonyHttpAdapter response adapter depends on `symfony/http-foundation`
- Psr7Adapter response adapter depends on `psr/http-message`
- SymfonyRoutingAdapter route generator adapter depends on `symfony/routing`

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

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 ~158 days

Total

4

Last Release

1491d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/201923639205c79cb9820ccd84129f7f2d82f297c648f4a4dab4114a9c0650fa?d=identicon)[warslett](/maintainers/warslett)

---

Top Contributors

[![warslett](https://avatars.githubusercontent.com/u/5106820?v=4)](https://github.com/warslett "warslett (58 commits)")

---

Tags

doctrinepaginationphpsortingsymfonytabletable-buildertwig

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/elastica-bundle

Elasticsearch PHP integration for your Symfony project using Elastica

1.3k17.2M47](/packages/friendsofsymfony-elastica-bundle)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[dunglas/doctrine-json-odm

An object document mapper for Doctrine ORM using JSON types of modern RDBMS.

6285.0M10](/packages/dunglas-doctrine-json-odm)[kphoen/rulerz

Powerful implementation of the Specification pattern

8831.3M6](/packages/kphoen-rulerz)[portphp/portphp

Data import/export workflow

2702.9M22](/packages/portphp-portphp)[happyr/doctrine-specification

Specification Pattern for your Doctrine repositories

452915.0k8](/packages/happyr-doctrine-specification)

PHPackages © 2026

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