Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
Toolbar
n/a
0 / 0
n/a
0 / 0
0
n/a
0 / 0
1<?php
2
3namespace Config;
4
5use CodeIgniter\Config\BaseConfig;
6use CodeIgniter\Debug\Toolbar\Collectors\Database;
7use CodeIgniter\Debug\Toolbar\Collectors\Events;
8use CodeIgniter\Debug\Toolbar\Collectors\Files;
9use CodeIgniter\Debug\Toolbar\Collectors\Logs;
10use CodeIgniter\Debug\Toolbar\Collectors\Routes;
11use CodeIgniter\Debug\Toolbar\Collectors\Timers;
12use CodeIgniter\Debug\Toolbar\Collectors\Views;
13
14/**
15 * --------------------------------------------------------------------------
16 * Debug Toolbar
17 * --------------------------------------------------------------------------
18 *
19 * The Debug Toolbar provides a way to see information about the performance
20 * and state of your application during that page display. By default it will
21 * NOT be displayed under production environments, and will only display if
22 * `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
23 */
24class Toolbar extends BaseConfig
25{
26    /**
27     * --------------------------------------------------------------------------
28     * Toolbar Collectors
29     * --------------------------------------------------------------------------
30     *
31     * List of toolbar collectors that will be called when Debug Toolbar
32     * fires up and collects data from.
33     *
34     * @var list<class-string>
35     */
36    public array $collectors = [
37        Timers::class,
38        Database::class,
39        Logs::class,
40        Views::class,
41        // \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
42        Files::class,
43        Routes::class,
44        Events::class,
45    ];
46
47    /**
48     * --------------------------------------------------------------------------
49     * Collect Var Data
50     * --------------------------------------------------------------------------
51     *
52     * If set to false var data from the views will not be collected. Useful to
53     * avoid high memory usage when there are lots of data passed to the view.
54     */
55    public bool $collectVarData = true;
56
57    /**
58     * --------------------------------------------------------------------------
59     * Max History
60     * --------------------------------------------------------------------------
61     *
62     * `$maxHistory` sets a limit on the number of past requests that are stored,
63     * helping to conserve file space used to store them. You can set it to
64     * 0 (zero) to not have any history stored, or -1 for unlimited history.
65     */
66    public int $maxHistory = 20;
67
68    /**
69     * --------------------------------------------------------------------------
70     * Toolbar Views Path
71     * --------------------------------------------------------------------------
72     *
73     * The full path to the the views that are used by the toolbar.
74     * This MUST have a trailing slash.
75     */
76    public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
77
78    /**
79     * --------------------------------------------------------------------------
80     * Max Queries
81     * --------------------------------------------------------------------------
82     *
83     * If the Database Collector is enabled, it will log every query that the
84     * the system generates so they can be displayed on the toolbar's timeline
85     * and in the query log. This can lead to memory issues in some instances
86     * with hundreds of queries.
87     *
88     * `$maxQueries` defines the maximum amount of queries that will be stored.
89     */
90    public int $maxQueries = 100;
91
92    /**
93     * --------------------------------------------------------------------------
94     * Watched Directories
95     * --------------------------------------------------------------------------
96     *
97     * Contains an array of directories that will be watched for changes and
98     * used to determine if the hot-reload feature should reload the page or not.
99     * We restrict the values to keep performance as high as possible.
100     *
101     * NOTE: The ROOTPATH will be prepended to all values.
102     *
103     * @var list<string>
104     */
105    public array $watchedDirectories = [
106        'app',
107    ];
108
109    /**
110     * --------------------------------------------------------------------------
111     * Watched File Extensions
112     * --------------------------------------------------------------------------
113     *
114     * Contains an array of file extensions that will be watched for changes and
115     * used to determine if the hot-reload feature should reload the page or not.
116     *
117     * @var list<string>
118     */
119    public array $watchedExtensions = [
120        'php', 'css', 'js', 'html', 'svg', 'json', 'env',
121    ];
122
123    /**
124     * --------------------------------------------------------------------------
125     * Ignored HTTP Headers
126     * --------------------------------------------------------------------------
127     *
128     * CodeIgniter Debug Toolbar normally injects HTML and JavaScript into every
129     * HTML response. This is correct for full page loads, but it breaks requests
130     * that expect only a clean HTML fragment.
131     *
132     * Libraries like HTMX, Unpoly, and Hotwire (Turbo) update parts of the page or
133     * manage navigation on the client side. Injecting the Debug Toolbar into their
134     * responses can cause invalid HTML, duplicated scripts, or JavaScript errors
135     * (such as infinite loops or "Maximum call stack size exceeded").
136     *
137     * Any request containing one of the following headers is treated as a
138     * client-managed or partial request, and the Debug Toolbar injection is skipped.
139     *
140     * @var array<string, string|null>
141     */
142    public array $disableOnHeaders = [
143        'X-Requested-With' => 'xmlhttprequest', // AJAX requests
144        'HX-Request'       => 'true',           // HTMX requests
145        'X-Up-Version'     => null,             // Unpoly partial requests
146    ];
147}