Skip to content

Commit f78b67a

Browse files
authored
Merge pull request #8564 from kenjis/docs-improve-debugging
docs: improve debugging
2 parents 0189cad + eb03676 commit f78b67a

File tree

3 files changed

+51
-23
lines changed

3 files changed

+51
-23
lines changed

user_guide_src/source/database/events.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ uses this to collect the queries to display in the Toolbar.
1515
The Events
1616
**********
1717

18+
.. _database-events-dbquery:
19+
1820
DBQuery
1921
=======
2022

21-
This event is triggered whenever a new query has been run, whether successful or not. The only parameter is
22-
a :doc:`Query </database/queries>` instance of the current query. You could use this to display all queries
23-
in STDOUT, or logging to a file, or even creating tools to do automatic query analysis to help you spot
24-
potentially missing indexes, slow queries, etc.
23+
This event is triggered whenever a new query has been run, whether successful or
24+
not. The only parameter is a :doc:`Query </database/queries>` instance of the
25+
current query.
26+
27+
You could use this to display all queries in STDOUT, or logging to a file, or
28+
even creating tools to do automatic query analysis to help you spot potentially
29+
missing indexes, slow queries, etc.
2530

26-
An example usage might be:
31+
An example to log all queries:
2732

2833
.. literalinclude:: events/001.php

user_guide_src/source/installation/troubleshooting.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,4 @@ After that, reload the page. You will see the error and the back trace.
102102
CodeIgniter Error Logs
103103
----------------------
104104

105-
CodeIgniter logs error messages, according to the settings in **app/Config/Logger.php**.
106-
107-
You can adjust the error threshold to see more or fewer messages. See :ref:`Logging <logging-configuration>` for details.
108-
109-
The default configuration has daily log files stored in **writable/logs**.
110-
It would be a good idea to check them if things aren't working the way you expect!
105+
See :ref:`codeigniter-error-logs`.

user_guide_src/source/testing/debugging.rst

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,46 @@
1-
**************************
1+
##########################
22
Debugging Your Application
3-
**************************
3+
##########################
44

55
.. contents::
66
:local:
77
:depth: 2
88

9-
================
10-
Replace var_dump
11-
================
9+
*************
10+
Checking Logs
11+
*************
1212

13-
While using XDebug and a good IDE can be indispensable to debug your application, sometimes a quick ``var_dump()`` is
14-
all you need. CodeIgniter makes that even better by bundling in the excellent `Kint <https://kint-php.github.io/kint/>`_
15-
debugging tool for PHP. This goes way beyond your usual tool, providing many alternate pieces of data, like formatting
16-
timestamps into recognizable dates, showing you hexcodes as colors, display array data like a table for easy reading,
17-
and much, much more.
13+
.. _codeigniter-error-logs:
14+
15+
CodeIgniter Error Logs
16+
======================
17+
18+
CodeIgniter logs error messages, according to the settings in **app/Config/Logger.php**.
19+
20+
The default configuration has daily log files stored in **writable/logs**.
21+
It would be a good idea to check them if things aren't working the way you expect!
22+
23+
You can adjust the error threshold to see more or fewer messages. See
24+
:ref:`Logging <logging-configuration>` for details.
25+
26+
Logging All SQL Queries
27+
=======================
28+
29+
All SQL queries issued by CodeIgniter can be logged.
30+
See :ref:`Database Events <database-events-dbquery>` for details.
31+
32+
********************
33+
Replacing var_dump()
34+
********************
35+
36+
While using Xdebug and a good IDE can be indispensable to debug your application,
37+
sometimes a quick ``var_dump()`` is all you need. CodeIgniter makes that even
38+
better by bundling in the excellent `Kint <https://kint-php.github.io/kint/>`_
39+
debugging tool for PHP.
40+
41+
This goes way beyond your usual tool, providing many alternate pieces of data,
42+
like formatting timestamps into recognizable dates, showing you hexcodes as colors,
43+
display array data like a table for easy reading, and much, much more.
1844

1945
Enabling Kint
2046
=============
@@ -33,6 +59,7 @@ The ``d()`` method dumps all of the data it knows about the contents passed as t
3359
allows the script to continue executing:
3460

3561
.. literalinclude:: debugging/001.php
62+
:lines: 2-
3663

3764
dd()
3865
----
@@ -45,14 +72,15 @@ trace()
4572
This provides a backtrace to the current execution point, with Kint's own unique spin:
4673

4774
.. literalinclude:: debugging/002.php
75+
:lines: 2-
4876

4977
For more information, see `Kint's page <https://kint-php.github.io/kint//>`_.
5078

5179
.. _the-debug-toolbar:
5280

53-
=================
81+
*****************
5482
The Debug Toolbar
55-
=================
83+
*****************
5684

5785
The Debug Toolbar provides at-a-glance information about the current page request, including benchmark results,
5886
queries you have run, request and response data, and more. This can all prove very useful during development

0 commit comments

Comments
 (0)