Debugging Mode
Laravel DataTables includes a debugging mode that helps you inspect the SQL queries and request parameters being used when processing DataTables requests.
Setup
- Set
APP_DEBUG=truein your.envfile:
APP_DEBUG=true
- Make sure
APP_ENVis set tolocalortestingin development environments.
[!WARNING] Never enable
APP_DEBUG=truein production. Exposing SQL queries and application internals is a security risk.
How It Works
When APP_DEBUG=true, Laravel DataTables automatically intercepts the response and appends debugging information. The debug data is only included when:
APP_DEBUGistrue- The request is an AJAX/DataTables request
- The response is in JSON format
Example Response
When debugging is enabled, your JSON response includes additional queries and input fields:
{ "draw": 1, "recordsTotal": 10, "recordsFiltered": 3, "data": [ { "id": 414, "name": "Abel Cole", "created_at": "2016-07-31 23:26:10", "updated_at": "2016-07-31 23:26:10" } ], "queries": [ { "query": "select count(*) as aggregate from (select '1' as `row_count` from `users` where `users`.`deleted_at` is null) count_row_table", "bindings": [], "time": 1.84 }, { "query": "select * from `users` where `users`.`deleted_at` is null order by `name` asc limit 10 offset 0", "bindings": [], "time": 1.8 } ], "input": { "draw": "1", "columns": [ { "data": "id", "name": "", "searchable": "true", "orderable": "true", "search": { "value": "", "regex": "false" } } ], "order": [ { "column": "1", "dir": "asc" } ], "start": "0", "length": "10", "search": { "value": "", "regex": "false" } }}
Debug Output Fields
| Field | Description |
|---|---|
queries |
Array of executed SQL queries with bindings and execution time |
input |
The complete DataTables request parameters including columns, order, and search settings |
Query Object Structure
Each query object contains:
| Property | Type | Description |
|---|---|---|
query |
string | The SQL query string with placeholder bindings |
bindings |
array | Parameter values bound to the query |
time |
float | Execution time in milliseconds |
See Also
- Error Handler - Configure error handling
- General Settings - Configuration options