CodeIgniter Forums
Trouble with debug bar? Solutions? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Trouble with debug bar? Solutions? (/showthread.php?tid=88086)



Trouble with debug bar? Solutions? - MathewTamra - 07-17-2023

I'm experiencing difficulties with returning JSON responses through AJAX due to the debug bar. Is there a solution to disable the debug bar specifically for certain controllers? Ideally, I'd like to disable it for individual routes or functions within a controller. Thank you!



Got my answer:  I edited this file and adjust the $excludePaths property. Add your controller names (e.g., 'my_controller') within an array to exclude them from debug bar inclusion. Utilize dedicated route groups with custom middleware. Define a "no_debug" middleware that sets CI_DEBUG to false before calling your controller method. Apply this middleware to the desired routes.
Disabling for Functions:

Conditional Check: Inside your controller function, add a check: if(!is_cli()) define('CI_DEBUG', false); This disables debug only for web requests (not command-line).
 Here's the official CodeIgniter documentation link which i used on debugging and the toolbar configuration: https://stackoverflow.com/questions/omeglz/13562950/debugging-in-codeigniter-and-mvc


RE: Trouble with debug bar? Solutions? - ozornick - 07-17-2023

Yes, set urls in config/Filters.php, see docs