rollbar / rollbar-php-laravel

Rollbar error monitoring integration for Laravel projects
https://docs.rollbar.com/docs/laravel
140 stars 39 forks source link

Cannot disable auto-discovery #60

Closed denitsa-md closed 5 years ago

denitsa-md commented 6 years ago

I want to disable auto-discovery and register the service provider manually since I don't want rollbar on development. I tried doing it but to no avail.

I read the docs here https://docs.rollbar.com/docs/laravel#section-installation.

I have the following entry in my composer.json

  "extra": {
    "laravel": {
      "dont-discover": [
        "rollbar/rollbar-laravel"
      ]
    }

I have the following in my AppServiceProvider:register():

        if ($this->app->environment(['staging', 'production'])) {
            $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
        }

I have version:

            "name": "rollbar/rollbar-laravel",
            "version": "v4.0.0",

I've also run php artisan package:discover after the update to composer.json and the package is correctly not present in Discovered package: lines that are generated from the command.

My temporary solution is to remove the ROLLBAR_TOKEN from my local .env file.

Is there something I'm missing?

jessewgibbs commented 6 years ago

Hi denitsa-cm,

We'll get one of our library maintainers to take a look at your question and respond soon.

nickbryan commented 5 years ago

@ArturMoczulski any update on this?

kedarv commented 5 years ago

This turned out to be an easy fix. The documentation just needs to be more explicit if you're copy pasting from the instructions. To resolve, just remove Rollbar\Laravel\RollbarServiceProvider::class, from your providers array in config/app.php

Then, conditionally load the provider in your AppServiceProvider.

As we can see here, Laravel will attempt to register every service provider in the array in config/app.php

Hope this helps!

ArturMoczulski commented 5 years ago

Great! Thanks @kedarv I'll amend the docs right now