CodeIgniter Forums
Debug toolbar on production - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Debug toolbar on production (/showthread.php?tid=80830)



Debug toolbar on production - Vodecki - 12-23-2021

Is there any possibility to enable debug toolbar on production for some user privillege or in specific controller ?
in CI3 it was quite easy to enable it by  for example in this way

if($user[['role]=='admin') $this->output->enable_profiler(true)

is something similar possible in CI4 ?


RE: Debug toolbar on production - captain-sensible - 12-24-2021

good question so that general users can't see output , but admin you can ?

The way I enable or disable debug is via index.php at public like so :

Code:
$_SERVER['CI_ENVIRONMENT'] = 'development';
// or
$_SERVER['CI_ENVIRONMENT'] = 'production';

generally I do all my testing on local , so that basically to all intents and purposes live is a clone of whats on local. However I have done some live editing of code , (big mistake ) which went pear shape. I fixed it by editing live the index.php to have the line quoted above as "development" . It gave me output from live, with the clue how to fix it.

index.php and .env pretty global so i can't think how you would do that.


RE: Debug toolbar on production - kenjis - 12-24-2021

(12-23-2021, 01:47 AM)Vodecki Wrote: Is there any possibility to enable debug toolbar on production for some user privillege or in specific controller ?
in CI3 it was quite easy to enable it by  for example in this way

if($user[['role]=='admin') $this->output->enable_profiler(true)

is something similar possible in CI4 ?

No. CI4 uses the constant to enable debug toolbar.
As you know constants cannot change on the runtime.