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

luisferfranco's avatar

Question about laravel-debugbar in production

I'm sorry, maybe this is only my expectations as newbie deploying apps.

In development I love to use barryvdh/laravel-debugbar. When I use npm run dev it does what I expect, to load all the dev things. But when I do npm run build I was expecting that all the dev things were going to be left out. Then I realized npm is just for the js assets.

So, do I have to manually remove from composer.json the reference to the debugbar before building the app? Do I have to run composer install? Is there something like npm run build that I have to run for composer?

0 likes
3 replies
MohamedTammam's avatar

For deploying you need to run composer install.

For debugger and any other development setup your Laravel application. Change your .env variables APP_ENV and APP_DEBUG to be

APP_ENV=production
APP_DEBUG=false

With that, laravel-debugger will be disabled in production.

1 like
nexxai's avatar

If you installed it using the command on the debugbar Github page (composer require barryvdh/laravel-debugbar --dev), it will only be installed in the require-dev section of composer.json. Then when you run composer install --no-dev on your production server, it will not be installed since it won't be in the main require section. If you installed it by hand on your local machine and didn't add the --dev flag, you can just just manually edit the composer.json and move it from one section to the other.

Additionally, as @mohamedtammam mentioned, debugbar has its own check to see what the APP_ENV value is for the current running instance; if it's set to production, it will not run at all, so just make sure your production instances are configured correctly and you will be protected.

1 like
luisferfranco's avatar

Thanks to both of you. I did the composer --no-dev and worked great, I'll try the changes in the .env file

Thanks!

Please or to participate in this conversation.