Welcome Guest, Not a member yet? Register   Sign In
Is there a way to turn off the debugbar for a specific controller/route
#1

As the title says, im seeking a way to disable the debugbar for specific controllers/routes.

Thank you.
Reply
#2

The debugbar only shows in development mode if you change to production it
will not show.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

Thank you InsiteFX, I know this already, but that doesnt help during development Smile

I've came up with a solution, I've basically placed the following code in the Config/Boot/development.php file just above the CI_DEBUG definition:

PHP Code:
if (!empty($_SERVER['REQUEST_URI']) && substr($_SERVER['REQUEST_URI'], 0) === "/css/")
{
    define('CI_DEBUG'0);



Not sure if it is the best way, but it works.
Reply
#4

Hey crazyR - the Toolbar is attached via controller filter, so you can change the way it's specified to exclude certain uri's there. See the filters docs for more info.
Reply
#5

Thank you kilishan, That is exactly what I was looking for Smile

I did brush pass that documentation earlier but for some reason I must not have been paying enough attention to realize its importance.

Thanks again.
Reply
#6

@crazyR
> As the title says, im seeking a way to disable the debugbar for specific controllers/routes.

I am not sure of the order that CI_DEBUG is called but I prefer defining the debug boolean constant in index.php.

You could try a conditional grouping of the /Controller/config/routes.php -> $route1 = "route"; and the debug constant will be contained in the same file.
Reply
#7

(This post was last modified: 02-25-2021, 10:00 AM by tibszabo.)

(11-06-2019, 07:43 AM)crazyR Wrote: As the title says, im seeking a way to disable the debugbar for specific controllers/routes.

Thank you.

For me, this is working:

before showing the view create a session var:

PHP Code:
session()->set('skip_debug',true); 

then in the app\Config\Toolbar.php create a constructor then remove the View::class if that var is present.

PHP Code:
public function __construct() {
        parent::__construct();
        
        
if (session()->get('skip_debug') === true) {
            session()->remove('skip_debug');
            array_splice($this->collectors,array_search(Views::class,$this->collectors),1);
        }
    
Reply




Theme © iAndrew 2016 - Forum software by © MyBB