Skip debug toolbar collection for AJAX requests

This commit is contained in:
DevSoftTech Server 2026-03-01 01:28:27 +05:30
parent 2834362e8f
commit d1c9397aa9

View File

@ -43,8 +43,14 @@ Events::on('pre_system', static function (): void {
* If you delete, they will no longer be collected.
*/
if (CI_DEBUG && ! is_cli()) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
service('toolbar')->respond();
$isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH'])
&& strtolower((string) $_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
if (! $isAjax) {
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
service('toolbar')->respond();
}
// Hot Reload route - for framework use on the hot reloader.
if (ENVIRONMENT === 'development') {
service('routes')->get('__hot-reload', static function (): void {