DataTables Library

The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.

Documentation

# DataTables Library

DbM\DataTables is a standalone PHP library maintained with DBM Platform. It provides reusable backend and rendering components for database-backed tables. It is separate from the DBM Framework runtime, although platform applications can integrate it with their repositories, database adapter, HTTP request, and templates.

# Main components

  • DataTableParams is an immutable value object for the current page, page size, sort key, direction, and filters. fromRequest() accepts page, per_page, sort, and dir, as well as filters in filter[key] or filter_key form. Global search is normalized to the query filter and accepts q as an input alias.
  • DataTableService paginates through a RepositoryInterface (paginate()) or a supplied database adapter and a raw SELECT (paginateRaw()). Raw queries use explicit sortable, filterable, and searchable alias maps. Pagination, filtering, sorting, and count results are returned in DataTableResult.
  • ConfigDataTableInterface supplies the table schema and application-specific filters, buttons, custom rows, rendering mode, and request URL.
  • DataTableRenderer builds the table markup and response data. ApiDataTableResponseBuilder selects the PHP, AJAX, or API response path according to the configuration.
  • Database and repository interfaces keep persistence integration replaceable; the library also has an HTTP request abstraction and a small translator utility.

# Integration outline

Create an application configuration implementing ConfigDataTableInterface, provide a compatible repository or database adapter, parse incoming query parameters with DataTableParams::fromRequest(), and pass the resulting data to the renderer or response builder. Keep SQL aliases used in raw pagination mapped explicitly; do not derive SQL identifiers directly from request values.

The configuration contract names PHP, AJAX, and API modes, and the response builder contains paths for each. However, the current renderer includes a non-PHP availability restriction, so verify the installed edition and current library behavior before relying on AJAX/API rendering. This library is proprietary and subject to the DBM Platform license.