PHPackages                             hstanleycrow/easyphpdatatablecrud - 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. [Admin Panels](/categories/admin)
4. /
5. hstanleycrow/easyphpdatatablecrud

ActiveLibrary[Admin Panels](/categories/admin)

hstanleycrow/easyphpdatatablecrud
=================================

PHP UI builder that renders ready-to-use CRUD datatables on top of EasyPHPDatatables

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

Since Nov 27Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependencies (8)Versions (5)Used By (1)

EasyPHPDatatableCRUD
====================

[](#easyphpdatatablecrud)

PHP UI builder that renders ready-to-use CRUD datatables on top of [EasyPHPDatatables](https://github.com/hstanleycrow/EasyPHPDatatables). You describe a table once (columns, joins, action buttons) and the builder outputs the markup, the CSS/JS resource tags and the DataTables server-side wiring.

Spanish version: [README.es.md](README.es.md).

Scope: what it does and what it doesn't
---------------------------------------

[](#scope-what-it-does-and-what-it-doesnt)

This library owns the **listing** (the "read" of CRUD): it renders the table, wires the DataTables server-side processing and paints the action buttons. The buttons are just links to paths you choose (`user/edit/1/`, `user/delete/1/`, `user/add/`). **Building the create / edit / delete pages behind those links is your responsibility** — the library does not generate forms or perform writes.

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

[](#requirements)

- PHP `^8.2`
- `ext-pdo`, `ext-json`
- A **MySQL database** with at least one table to list
- `hstanleycrow/easyphpdatatables` `^2.0`
- PHP `^8.2`
- `ext-pdo`, `ext-json`
- A PDO-MySQL database
- `hstanleycrow/easyphpdatatables` `^2.0`

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

[](#installation)

```
composer require hstanleycrow/easyphpdatatablecrud
```

How it works
------------

[](#how-it-works)

Three pieces cooperate:

1. **A definition class** describing the table (columns, primary key, join, buttons). The library resolves it from `DT_DEFINITIONS_NAMESPACE` + the model name, so `new DatatableUIBuilder('user')` loads `{DT_DEFINITIONS_NAMESPACE}\User`.
2. **A page** that renders the table and points it at an AJAX endpoint.
3. **An AJAX endpoint** that answers DataTables server-side processing requests.

A full runnable sample lives in [examples/](examples/).

Running the bundled example
---------------------------

[](#running-the-bundled-example)

The example lists a `users` table and shows styled action buttons built with [EasyPHPWebComponents](https://github.com/hstanleycrow/EasyPHPWebComponents) icons.

1. **Install dependencies** (dev deps included, so the example buttons resolve):

    ```
    composer install
    ```
2. **Create a database and load the sample table + seed rows:**

    ```
    mysql -u root -p your_database  The datatable only reads columns that actually exist. Every `db_name` (and any join in `getJoinQuery()`) must reference real columns, or the AJAX endpoint returns an SQL error.

### 1. Define the table

[](#1-define-the-table)

```
