PHPackages                             hstanleycrow/easyphpdatatables - 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. hstanleycrow/easyphpdatatables

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

hstanleycrow/easyphpdatatables
==============================

Standalone PHP server-side processing engine for DataTables.net: query, paginate, filter and order from a single PHP table definition.

v2.1.0(1mo ago)0392MITPHPPHP ^8.2

Since Nov 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hstanleycrow/EasyPHPDatatables)[ Packagist](https://packagist.org/packages/hstanleycrow/easyphpdatatables)[ Docs](https://github.com/hstanleycrow/EasyPHPDatatables)[ RSS](/packages/hstanleycrow-easyphpdatatables/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (9)Versions (9)Used By (2)

EasyPHPDatatables
=================

[](#easyphpdatatables)

Free, standalone PHP library for the server-side processing of [DataTables.net](https://datatables.net): querying, pagination, filtering and ordering. You declare each table once as a PHP class, and the library builds the query, the AJAX response and the client-side init script for you.

It does **not** ship a UI framework. It renders the `` skeleton and the DataTables init JavaScript, and answers the AJAX request with JSON.

- **Requirements:** PHP &gt;= 8.2, a PDO-MySQL database.
- **License:** MIT

> Looking for ready-made add/edit/delete buttons on top of this? See [PHPDatatableUIBuilder](https://github.com/hstanleycrow/PHPDatatableUIBuilder).

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

[](#installation)

```
composer require hstanleycrow/easyphpdatatables
```

Architecture in one line
------------------------

[](#architecture-in-one-line)

The browser loads a page that renders a `` plus an init script. That script points its `ajax` option at **an endpoint you own** in your webroot, which calls `SSP::handle()` and returns JSON. You never expose files inside `vendor/`.

Quick start
-----------

[](#quick-start)

### 1. Configure your environment (`.env`)

[](#1-configure-your-environment-env)

```
DATABASE_HOST = "127.0.0.1"
DATABASE_NAME = "my_database"
DATABASE_USERNAME = "root"
DATABASE_PASSWORD = ""

DT_DEFINITIONS_NAMESPACE = 'App\DatatableDefinitions'
DT_LANGUAGE = 'es'
DT_PAGE_LENGTH = 25
DT_DATE_FORMAT = 'd/m/Y'
DT_TABLE_CLASSES = 'table table-striped'
```

Every `DT_*` key is optional and falls back to a sensible default (see [Configuration](#configuration)).

### 2. Declare a table definition

[](#2-declare-a-table-definition)

One class per table, inside the namespace you set in `DT_DEFINITIONS_NAMESPACE`. The class name matches the definition name you request (`user` -&gt; `User`).

```
