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

abduljakul-salsalani's avatar

deploying my application to heroku returns a service provider error

I get an error when deploying my app to heroku.

When I do

$ git push heroku master


remote:          - Installing nexmo/laravel (1.1.0): Downloading (100%)
remote:          - Installing intervention/imagecache (2.3.3): Downloading (100%)
remote:          - Installing owenmelbz/laravel-pwa-manifest (0.0.3): Downloading (100%)
remote:          - Installing pusher/pusher-php-server (v3.0.1): Downloading (100%)
remote:        Generating optimized autoload files

remote:        > Illuminate\Foundation\ComposerScripts::postInstall
remote:        > php artisan optimize
remote:
remote:        In ProviderRepository.php line 208:
remote:
remote:          Class 'Barryvdh\Debugbar\ServiceProvider' not found
remote:

0 likes
6 replies
xmarks's avatar

First of all, on Laravel 5.5+ you do not need to declare a Service Provider, as it is done automatically.

Second, when installing Debugbar, by default it is required on dev Environment. Usually Heroku is considered a production environment, so it does not install packages under dev.

If you want Debugbar on Heroku, you have to modify your composer.json file, and move the DebugBar Package from require-dev to require.

Then push your changes again. Debugbar will now install as a package, and the Service Provider class will be found.

xmarks's avatar

Then you have to take the other steps I mentioned, since you have to keep the Provider. Again:

  • when installing Debugbar, by default it is required on dev Environment. Usually Heroku is considered a production environment, so it does not install packages under dev.
  • If you want Debugbar on Heroku, you have to modify your composer.json file, and move the DebugBar Package from require-dev to require.
  • Then push your changes again. Debugbar will now install as a package, and the Service Provider class will be found.

After this, DebugBar should work. If you do not want it active on Heroku, change the APP_DEBUG parameter, on your .env file, from true to false.

xmarks's avatar

yeah, but you need it locally.

The Provider is taken from the "Vendor" folder. Since DerbugBar is not being installed on Heroku, then the Provider can't be found from the "Vendor" folder, and thus it's giving you the error.

So the solution: You need to install it, and then deactivate it.

How to deactivate it:

After this, DebugBar should work. If you do not want it active on Heroku, change the APP_DEBUG parameter, on your .env file, from true to false.

Please or to participate in this conversation.