Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dbehterev's avatar

Laravel Debugbar continues injecting own code on a page even is completely disabled

Hello! I tried:

  • .env: DEBUGBAR_ENABLED=false / APP_DEBUG=false
  • web.php: Config::set('debugbar.enabled', false); (at the top)
  • config\debugbar.php: 'inject' => false
  • php artisan config:cache / composer dump-autoload

But in generated source code of page I could see JS template made by debugbar. Full deleting debugbar is not appropriate for me. Thanks for any advice.

0 likes
11 replies
Sergiu17's avatar

Open config\app.php inside providers array there should be

Barryvdh\Debugbar\ServiceProvider::class,

Remove it

1 like
dbehterev's avatar

Thanks for answer. It seems that debugbar is autoloading (as I remember this feature works for L5.5 and newer) because I don't see debugbar class in 'providers' array.

Snapey's avatar

The docs say

You can enable or disable the debugbar during run time.

\Debugbar::enable();
\Debugbar::disable();
dbehterev's avatar

@Snapey that works, but JS code continues injecting on the page even in prod mode.

Sergiu17's avatar
composer require barryvdh/laravel-debugbar --dev # did you add --dev flag? when you installed?

With --dev and APP_DEBUG=false the debug bar disappear

Snapey's avatar

if installed correctly with composer, it should not be included in your production build

dbehterev's avatar

@Sergiu17 in my composer.json I could see:

   "require-dev": {
        "barryvdh/laravel-debugbar": "^3.1",
Sergiu17's avatar
composer remove barryvdh/laravel-debugbar

Remove package with composer remove

dbehterev's avatar

@Sergiu17 just reinstalled debugbar. After deleting no any debug JS code in the page. After that I installed it again:

composer require barryvdh/laravel-debugbar --dev

Behaviour the same: debugbar is injecting own code despite being disabled.

36864's avatar

Try setting your APP_ENV to production.

dbehterev's avatar

sorry for my misleading everyone on this forum, but I found the component that injected extra code on a page - tightenco/ziggy. Thanks!

Please or to participate in this conversation.