PHPackages                             laravel-enso/tables - 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. laravel-enso/tables

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

laravel-enso/tables
===================

Server-side data tables and export backend for Laravel Enso

5.1.12(2w ago)63355.1k↑107.6%76[1 issues](https://github.com/laravel-enso/tables/issues)20MITPHPPHP ^8.0CI failing

Since Nov 22Pushed 2w ago20 watchersCompare

[ Source](https://github.com/laravel-enso/tables)[ Packagist](https://packagist.org/packages/laravel-enso/tables)[ Docs](https://github.com/laravel-enso/tables)[ RSS](/packages/laravel-enso-tables/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (23)Versions (520)Used By (20)

Tables
======

[](#tables)

[![License](https://camo.githubusercontent.com/dc38e7728472dae49762c5f2766f2378532f1432aa3c9c7e2c7cbe22b0fbf4e1/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f7461626c65732f6c6963656e7365)](LICENSE)[![Stable](https://camo.githubusercontent.com/3c8eddd79fbfae25fff25716e2fec55d71afcb3a0f1ba46b5f3ccf7bb201297b/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f7461626c65732f76657273696f6e)](https://packagist.org/packages/laravel-enso/tables)[![Downloads](https://camo.githubusercontent.com/c3568189dd5eeef3bb923b33d8f79d6fed0e1acd08c3f114b04a3f7f90cc0742/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f7461626c65732f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/tables)[![PHP](https://camo.githubusercontent.com/da7cf113b588d26fe679dfefe4a15009272ed358ad4e786ad3c78b45faa61d69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d3737376262342e737667)](composer.json)[![Issues](https://camo.githubusercontent.com/0174c8144c28186fb700cb812a60968d7104aa66271c50ef9a5450ef2c900ee1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f7461626c65732e737667)](https://github.com/laravel-enso/tables/issues)[![Merge Requests](https://camo.githubusercontent.com/1f5a2a66a6ce57584a28e795c79823ed8b1b89a376efea36234edc0c16c31877/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f7461626c65732e737667)](https://github.com/laravel-enso/tables/pulls)

Description
-----------

[](#description)

Tables is the backend engine behind Enso's server-side data tables.

The package reads a JSON table template, validates it, builds the frontend bootstrap payload, turns incoming column and meta state into a normalized request object, applies search and filter pipelines to an Eloquent query, computes row payloads, totals, pagination metadata, and can queue large spreadsheet exports with progress notifications.

It is one of the core Enso infrastructure packages and is designed to be reused by any backend module that exposes list views.

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

[](#installation)

Install the package:

```
composer require laravel-enso/tables
```

Publish the optional assets when you want local overrides:

```
php artisan vendor:publish --tag=tables-config
php artisan vendor:publish --tag=tables-mail
```

The package also ships stubs for new table builders, actions, and JSON templates:

```
php artisan vendor:publish --provider="LaravelEnso\Tables\AppServiceProvider"
```

When template caching is enabled, clear cached templates on deploy:

```
php artisan enso:tables:clear
```

Features
--------

[](#features)

- JSON template DSL for columns, buttons, controls, filters, structure, and styling.
- Dedicated controller traits for init, table data, and Excel export endpoints.
- Search, filter, interval, sort, and pagination normalization through a request/config pipeline.
- Column computors for enums, numbers, dates, datetimes, translations, resources, model methods, and cents.
- Aggregated totals, averages, and custom/raw totals at table level.
- Queue-based spreadsheet exports with chunked fetching, multi-sheet splitting, and mail/database/broadcast notifications.
- Uses `laravel-enso/mails` for export completion mail layout and preview registration.
- Template caching and optional row-count caching for large datasets.
- Extension points for dynamic templates and batch row actions.
- PHPUnit helpers for datatable endpoint testing.

Usage
-----

[](#usage)

### 1. Implement a table builder

[](#1-implement-a-table-builder)

Each table builder implements `LaravelEnso\Tables\Contracts\Table`:

```
use Illuminate\Database\Eloquent\Builder;
use LaravelEnso\Tables\Contracts\Table;

class Users implements Table
{
    public function __construct(private TableRequest $request)
    {
    }

    public function query(): Builder
    {
        return User::query()->select(['id', 'email', 'is_active']);
    }

    public function templatePath(): string
    {
        return __DIR__.'/../Templates/users.json';
    }
}
```

### 2. Expose the three backend endpoints

[](#2-expose-the-three-backend-endpoints)

The package controller traits are intentionally small:

- `Init` loads the builder and returns the validated template payload
- `Data` applies request state and returns rows plus meta
- `Excel` prepares the queued export flow and emits `ExportStarted`

```
use Illuminate\Routing\Controller;
use LaravelEnso\Tables\Traits\Init;
use LaravelEnso\Tables\Traits\Data;
use LaravelEnso\Tables\Traits\Excel;

class InitTable extends Controller
{
    use Init;

    protected string $tableClass = Users::class;
}

class TableData extends Controller
{
    use Data;

    protected string $tableClass = Users::class;
}

class ExportExcel extends Controller
{
    use Excel;

    protected string $tableClass = Users::class;
}
```

### 3. Define the JSON template

[](#3-define-the-json-template)

At minimum, a table template needs:

- `routePrefix`
- `buttons`
- `columns`

Example:

```
{
    "routePrefix": "administration.users",
    "buttons": ["create", "excel"],
    "controls": ["columns", "length", "reload", "reset", "style"],
    "appends": ["full_name"],
    "filters": [
        {
            "label": "Active",
            "data": "users.is_active",
            "value": null,
            "type": "boolean"
        }
    ],
    "columns": [
        {
            "label": "Email",
            "name": "email",
            "data": "users.email",
            "meta": ["searchable", "sortable"]
        },
        {
            "label": "Balance",
            "name": "balance",
            "data": "users.balance",
            "number": {
                "precision": 2,
                "symbol": "RON ",
                "template": "%s%v"
            },
            "meta": ["filterable", "total"]
        }
    ]
}
```

### Template structure

[](#template-structure)

Top-level attributes accepted by the validator include:

- `appends`, `auth`, `buttons`, `controls`
- `comparisonOperator`, `countCache`, `crtNo`
- `dataRouteSuffix`, `debounce`, `dtRowId`
- `filters`, `flatten`, `fullInfoRecordLimit`
- `lengthMenu`, `method`, `model`, `name`
- `preview`, `responsive`, `searchMode`, `searchModes`
- `selectable`, `strip`, `templateCache`
- `defaultSort`, `defaultSortDirection`, `totalLabel`

Column attributes:

- mandatory: `data`, `label`, `name`
- optional: `align`, `class`, `dateFormat`, `enum`, `meta`, `number`, `tooltip`, `resource`

Column meta flags:

- `average`, `boolean`, `clickable`, `cents`, `customTotal`
- `date`, `datetime`, `filterable`, `icon`, `method`
- `notExportable`, `nullLast`, `searchable`, `rawTotal`
- `rogue`, `slot`, `sortable`, `sort:ASC`, `sort:DESC`
- `total`, `translatable`, `notVisible`

Button structure:

- mandatory: `type`, `icon`
- types: `global`, `row`, `dropdown`
- actions: `ajax`, `export`, `href`, `router`
- optional attributes such as `routeSuffix`, `fullRoute`, `method`, `event`, `postEvent`, `confirmation`, `selection`, `tooltip`, and `slot`

Filters:

- mandatory: `label`, `data`, `value`, `type`
- optional: `slot`, `multiple`, `route`, `translated`, `params`, `pivotParams`, `custom`, `selectLabel`

Defaults also come from `config/tables.php`:

- cache behavior
- default buttons and controls
- style mapping
- export queue / sheet limits
- search modes and comparison operators

### Request and query pipeline

[](#request-and-query-pipeline)

Incoming frontend state is normalized through:

1. `ProvidesRequest` and `FilterAggregator`
2. `TemplateLoader` and `Template`
3. `Config`, which merges request meta onto template columns
4. `Data\Builders\Data`, `Meta`, and `Total`

The data pipeline applies:

- global search
- per-column filters
- numeric and date intervals
- default and custom sorting
- pagination limits
- model and array computors
- row actions and row style metadata

### Computors and formatting

[](#computors-and-formatting)

The package supports two families of computors:

- model computors such as `method` and `resource`
- array computors such as `enum`, `number`, `date`, `datetime`, `cents`, and `translator`

That lets you:

- render enum labels from legacy Enso enums or native PHP enums
- format numbers with symbols and precision
- format dates using the configured global or per-column format
- call model methods for derived values
- wrap values in API resources before returning them

### Export flow

[](#export-flow)

The export endpoint uses `Prepare`, then queues either `Jobs\Excel` or `Jobs\EnsoExcel`.

During export the package:

- rebuilds the filtered query
- streams rows in chunks through `Fetcher`
- writes one or more sheets with OpenSpout
- stores the file under `storage/app/{export.folder}`
- notifies the user with `ExportStarted`, `ExportDone`, or `ExportError`

Large tables can cap the export query chunk by implementing `LaravelEnso\Tables\Contracts\CustomExportChunk`:

```
use LaravelEnso\Tables\Contracts\CustomExportChunk;
use LaravelEnso\Tables\Contracts\Table;

class Products implements Table, CustomExportChunk
{
    public function exportChunk(): int
    {
        return 1000;
    }
}
```

The export service uses the lower value between the automatically computed chunk and the custom chunk, so table builders can reduce memory pressure without increasing the default chunk size for smaller exports.

### Caching and extension points

[](#caching-and-extension-points)

- `TemplateLoader` caches cacheable template fragments by template path, plus `cachePrefix()` when the table implements `DynamicTemplate`
- `TableCache` can invalidate cached counts on model create/delete
- custom batch jobs can extend `LaravelEnso\Tables\Services\Action`

### Tests

[](#tests)

The package ships focused unit coverage for:

- template builders and validators
- search, filter, interval, meta, and export builders
- template cache loading
- `TableCache` invalidation behavior

Useful local targets:

```
php artisan test --compact vendor/laravel-enso/tables/tests/units/Services/TemplateLoaderTest.php
php artisan test --compact vendor/laravel-enso/tables/tests/units/Traits/TableCacheTest.php
```

API
---

[](#api)

The package exposes three backend endpoints through the controller traits documented in the usage flow:

- `Init` returns the validated template payload and frontend bootstrap metadata
- `Data` resolves the request pipeline and returns rows, totals, pagination, and table meta
- `Excel` starts queued spreadsheet exports and emits the export-start event

At code level, the stable backend contract is `LaravelEnso\Tables\Contracts\Table`. Custom table builders should implement `query()` and `templatePath()`, while downstream modules should treat helper classes such as processors, calculators, computors, and normalizers as internal implementation details unless they are extended deliberately.

Depends On
----------

[](#depends-on)

Required Enso packages:

- [`laravel-enso/enums`](https://docs.laravel-enso.com/backend/enums.html) [↗](https://github.com/laravel-enso/enums)
- [`laravel-enso/filters`](https://docs.laravel-enso.com/backend/filters.html) [↗](https://github.com/laravel-enso/filters)
- [`laravel-enso/helpers`](https://docs.laravel-enso.com/backend/helpers.html) [↗](https://github.com/laravel-enso/helpers)
- [`laravel-enso/mails`](https://github.com/laravel-enso/mails) [↗](https://github.com/laravel-enso/mails)

Companion frontend package:

- [`@enso-ui/tables`](https://docs.laravel-enso.com/frontend/tables.html) [↗](https://github.com/enso-ui/tables)

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance97

Actively maintained with recent releases

Popularity52

Moderate usage in the ecosystem

Community43

Growing community involvement

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.9% 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 ~6 days

Total

481

Last Release

16d ago

Major Versions

1.9.29 → 2.0.02019-03-08

2.2.10 → 3.0.02019-10-12

2.2.11 → 3.0.112019-10-21

3.2.34 → 4.0.02020-06-24

4.19.1 → 5.0.02026-04-09

PHP version history (4 changes)0.9.0PHP &gt;=7.1.0

3.2.0PHP &gt;=7.4.0

4.8.1PHP &gt;=8.0

4.17.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (615 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (103 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (82 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (72 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (14 commits)")[![mauthi](https://avatars.githubusercontent.com/u/7204559?v=4)](https://github.com/mauthi "mauthi (10 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (5 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (5 commits)")[![clnt](https://avatars.githubusercontent.com/u/19330442?v=4)](https://github.com/clnt "clnt (4 commits)")[![stmitt](https://avatars.githubusercontent.com/u/1466567?v=4)](https://github.com/stmitt "stmitt (3 commits)")[![jlsjonas](https://avatars.githubusercontent.com/u/932193?v=4)](https://github.com/jlsjonas "jlsjonas (2 commits)")[![heyner29](https://avatars.githubusercontent.com/u/12703614?v=4)](https://github.com/heyner29 "heyner29 (2 commits)")[![DevIonut](https://avatars.githubusercontent.com/u/19207797?v=4)](https://github.com/DevIonut "DevIonut (2 commits)")

---

Tags

datatabledemojson-templatelaravellaravel-ensopaginationserversidedatatabledata tablelaravel-ensodata-table-server-side

### Embed Badge

![Health badge](/badges/laravel-enso-tables/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-enso-tables/health.svg)](https://phpackages.com/packages/laravel-enso-tables)
```

###  Alternatives

[laravel-enso/data-import

Excel Importer dependency for Laravel Enso

2044.0k6](/packages/laravel-enso-data-import)[laravel-enso/forms

JSON-based form builder for Laravel Enso

12354.2k85](/packages/laravel-enso-forms)[laravel-enso/tutorials

Tutorial management backend for Laravel Enso

1140.7k](/packages/laravel-enso-tutorials)[laravel-enso/select

Server-side option and typeahead builders for Laravel Enso

2661.2k72](/packages/laravel-enso-select)[laravel-enso/permissions

Permission management for Laravel Enso

1244.2k52](/packages/laravel-enso-permissions)[laravel-enso/comments

Comments Manager for Laravel Enso

1140.8k1](/packages/laravel-enso-comments)

PHPackages © 2026

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