Enable profiler globally - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Enable profiler globally (/showthread.php?tid=61590) Pages:
1
2
|
Enable profiler globally - PaulD - 04-29-2015 Just a quick one, I would like to be able to switch the profiler on and off globally. Code: $this->output->enable_profiler(TRUE); Best wishes, Paul. RE: Enable profiler globally - mwhitney - 04-29-2015 I'm not sure I understand what you're looking for. As far as I know, the code you included already works fine. In fact, I have a method in my base controller which does this. PHP Code: protected function showProfiler($frontEnd = true) Then I call the method in my base controller's constructor based on the ENVIRONMENT. My admin controller passes false to the method to bypass the check against the site.show_front_profiler setting. Obviously, some of this code isn't going to work in a base CI installation without the appropriate libraries, but the basic idea should still work. RE: Enable profiler globally - gadelat - 04-29-2015 He wants the option to enable it in autoload.php config. RE: Enable profiler globally - CroNiX - 04-29-2015 It takes a few lines of code to create a MY_Controller that does what the OP is asking for. RE: Enable profiler globally - gadelat - 04-29-2015 Sure, so does every other thing in autoload config RE: Enable profiler globally - PaulD - 04-29-2015 (04-29-2015, 11:23 AM)gadelat Wrote: He wants the option to enable it in autoload.php config. Yes, that is exactly what I meant. Perhaps not in the autoload file specifically but certainly somewhere relevant. Something like Code: /* OR even with the default display settings options as well: Code: $global_default_sections = array( Now that would be really, really helpful IMHO :-) I have just realized that this might be more complicated than I imagine because it would have to override the individual controller settings, but if it was available globally I don't imagine people would bother with it in individual controllers. So I suppose you would need three options, turn on for all pages, turn off for all pages, or leave it up to individual controllers to turn on if set. Then, when a site is ready for going live you could globally switch off the profiler so any controllers still set to show accidentally in individual controllers are overridden. During development you could set the global profiler on so when needed you can see it on all pages. Or you can just use it on a per controller basis as is the case now. I think people would like that, I certainly would, so just thought I would mention it as an idea. Best wishes, Paul. RE: Enable profiler globally - ivantcholakov - 04-29-2015 If it is introduced, maybe this global option should be not enforced in the same way for AJAX requests that output in non-HTML formats. For example, if an AJAX request returns in JSON format, the additional output from the profiler will damage the result, the client will be not able to parse it. RE: Enable profiler globally - ivantcholakov - 04-29-2015 I have never tried the profiler on CLI, in this case there should be a special profiler output, pure text. RE: Enable profiler globally - ivantcholakov - 04-29-2015 Related also with "REST support" http://forum.codeigniter.com/thread-61374.html REST response could be in different formats, the profiler output should not damage them. RE: Enable profiler globally - InsiteFX - 04-29-2015 This is how I do it with a profiler.php config file. Top of index.php or some place else. index.php PHP Code: /** MY_Controller PHP Code: /** |