Git Product home page Git Product logo

rollbar-php-laravel's Introduction

Rollbar for Laravel

Latest Version on Packagist Build Status Total Downloads

Rollbar error monitoring integration for Laravel projects. This library adds a listener to Laravel's logging component. Laravel's session information will be sent in to Rollbar, as well as some other helpful information such as 'environment', 'server', and 'session'.

Setup Instructions

  1. Sign up for a Rollbar account
  2. If you're using Laravel 5.6 and up follow Installation instructions in our Laravel 5.6 and up SDK docs
  3. If you're using Laravel 5.5 or lower follow Installation instructions in our Laravel 5.5 and lower SDK docs

Usage and Reference

For complete usage instructions and configuration reference, see our Laravel SDK docs.

Release History & Changelog

See our Releases page for a list of all releases, including changes.

Laravel 5.5 and below

Laravel 5.6 now requires PHP >= 7.1. As of rollbar/rollbar-php-laravel:v3.0.0 and up master also supports 5.6.

We still maintain support for Laravel 5.5 and below on branch laravel-5.5 and releases in the 2.x.x major.

Related projects

This project is a Laravel wrapper of Rollbar PHP: Rollbar PHP

A CakePHP-specific package is avaliable for integrating Rollbar PHP with CakePHP 2.x: CakeRollbar

A Flow-specific package is available for integrating Rollbar PHP with Neos Flow: m12/flow-rollbar

Yii package: baibaratsky/yii-rollbar

Yii2 package: baibaratsky/yii2-rollbar

Help / Support

If you run into any issues, please email us at [email protected]

For bug reports, please open an issue on GitHub.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Testing

Tests are in tests.

  • To run the tests: composer test
  • To fix code style issues: composer fix

Docker

Docker binaries are located in ./bin and can be run by simply executing bin/phpunit for example.

  • To run tests: bin/phpunit
  • To run code sniffer: bin/phpcs or bin/phpcbf
  • To run all supported versions: bin/phpunit-versions
  • To run composer : bin/composer install OR bin/composer update

rollbar-php-laravel's People

Contributors

arturmoczulski avatar arubacao avatar bastien-phi avatar brianr avatar bxsx avatar cyrusradfar avatar danielmorell avatar degecko avatar dougsisk avatar drbyte avatar ilm126 avatar jenssegers avatar jnbn avatar lowerends avatar maki10 avatar michaelscola avatar mingalevme avatar omranic avatar philbates35 avatar philsturgeon avatar potsky avatar rokob avatar sdebacker avatar throck95 avatar tobigumo avatar tobz-nz avatar tradjick avatar tylervigario avatar waltjones avatar zdavis-rollbar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rollbar-php-laravel's Issues

Failed to connect on local environment.

Rollbar is unable to connect to the api on my local environment.

On my local environment when I dd(Rollbar::info("Some info")); in RollbarServiceProvider.php I get the response:
Response {#318 ▼ -status: 0 -info: "Failed to connect to api.rollbar.com port 443: Connection refused" -uuid: "REDACTED" }

I am using Laravel Valet and am using a secure valet "domain."

I am also able to ping api.rollbar.com perfectly fine.

Issues with config caching

When utilizing php artisan config:cache it seems that the service-provider stops itself from registering.

This behavior seems to be caused by RollbarServiceProvider.php@stop which has the following lines

$level = getenv('ROLLBAR_LEVEL') ?: $this->app->config->get('services.rollbar.level', null);
$token = getenv('ROLLBAR_TOKEN') ?: $this->app->config->get('services.rollbar.access_token', null);

A simple fix would be removing the `getenv()´ and rather rely on the config which would be the normal Laravel way of doing things.

Rollbar-PHP-Laravel not built and Logger object not created

internal: https://app.intercom.io/a/apps/rlisg82q/inbox/inbox/849049/conversations/18362269083

User encountered this trouble while settings up:

"RollbarLogger::class is registered as a singleton...

$this->app->singleton(RollbarLogger::class, function ($app) {
...
this code is never run
...
});

so it never actually build the config and create the actual logger object

the RollbarServiceProvider registers the RollbarLogger by providing a closure

But this closure is never executed because the RollbarLogger class is never requested anywhere in the code

adding this in the controller

public function index(RollbarLogger $rollbarLogger)
{
$rollbarLogger->error('something');
return view('home');
}

forces the RollbarLogger clousure to be evaluated and thus works"

so i was wondering if this is something that is missing from the documentation or something with the SDK.

Cannot disable auto-discovery

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?

Cannot Log issue from Window Server

Notice the error cannot send from Windows Server

I install the Rollbar SDK wth composer, and work properly in Ubuntu, the log can send to Rollbar. But Windows can't.

I try to manually trigger a error using \Log:debug('this is a debug message') from command prompt.

And show the message: The system cannot find the path specified.

I try to narrow down the root cause, and found it came from getGitBranch() in /vendor/rollbar/rollbar/src/Defaults.php

However, still no idea why log issue cannot sent from Window Server..

Allow queued reporting

While having the option for asynchronous reporting via the rollbar-agent is great, it would be awesome to have the option to setup the package to use scheduled/queued reporting.

Seeing as many Laravel-apps already have systems configured for beanstalkd/Redis/Laravel Horizon it would be a great feature to be able to hook into these systems to improve performance over the default option.

Don't report validation reported

Here in my class App\Exceptions\Handler validation exception included in $dontReport array \Illuminate\Validation\ValidationException::class,.

 protected $dontReport = [
        \Illuminate\Auth\AuthenticationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
    ];

but roll bar reported me. Is it correct behaviour..?
screen shot from rollbar..
image

"Unable to send messages to Rollbar API. Produced response:" message before log item

Hi!

I use Laravel 5.1 and rollbar-php-laravel v2.4.1.

"Unable to send messages to Rollbar API. Produced response:" message before log item...
No response text, only this message.

I use other Laravel 5.1 project and rollbar-php-laravel v2.3.0 but no problem, only v2.4.1.

If "ROLLBAR_LEVEL=error" defined is .env AND run Log::error("test") is OK.
If run Log::info("test") then in logfile:
local.ERROR: Unable to send messages to Rollbar API. Produced response:

If "ROLLBAR_LEVEL" not defined in .env then Log::error("test") and Log::info("test") is OK!

log error with laravel 5.6 and Windows

I'm following the installation instructions in laravel 5.6 and php 7.2.4.
The Rollbar provider is loaded properly y put this in my Handler to test everything.
public function report(Exception $exception)

{
      \Log::error($exception);
      return parent::report($exception);
  }

but i don't obtain any log in rollbar and my laravel log is thowing this error

 [2018-05-10 12:22:57] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php:181)
[stacktrace]
#0 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(115): Illuminate\\Log\\LogManager->resolve(NULL)
#1 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(103): Illuminate\\Log\\LogManager->get(NULL)
#2 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogManager.php(602): Illuminate\\Log\\LogManager->driver()
#3 C:\\git\\geos-api\\vendor\
ollbar\
ollbar-laravel\\src\\RollbarServiceProvider.php(45): Illuminate\\Log\\LogManager->__call('listen', Array)
#4 [internal function]: Rollbar\\Laravel\\RollbarServiceProvider->boot()
#5 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(29): call_user_func_array(Array, Array)
#6 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#7 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#8 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(564): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#9 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(794): Illuminate\\Container\\Container->call(Array)
#10 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(777): Illuminate\\Foundation\\Application->bootProvider(Object(Rollbar\\Laravel\\RollbarServiceProvider))
#11 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}(Object(Rollbar\\Laravel\\RollbarServiceProvider), 15)
#12 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(778): array_walk(Array, Object(Closure))
#13 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Bootstrap\\BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#14 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(206): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap(Object(Illuminate\\Foundation\\Application))
#15 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(162): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#16 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(146): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#17 C:\\git\\geos-api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#18 C:\\git\\geos-api\\public\\index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#19 {main}
"} 

Any help??

Installation issue

Hi there, we're trying to install rollbar for Laravel, we've saw and follow the tutorial, composer install was succesfull (below require part of our composer.json)

`
"require": {
"php": ">=7.1",
"ext-gd": "",
"dimsav/laravel-translatable": "7.
",
"doctrine/dbal": "^2.5",
"fzaninotto/faker": "~1.4",
"hyn/multi-tenant": " ^4.0@dev",
"intervention/image": "^2.3",
"laravel/framework": "5.4.*",
"laravel/passport": "^3.0",
"laravel/tinker": "~1.0",
"league/flysystem-aws-s3-v3": "~1.0",
"phpoffice/phpspreadsheet": "dev-develop",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"rollbar/rollbar-laravel": "^2.2"
},

`

The dashboard can catch our errors but this one is coming all the time :

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Rollbar' not found

The class already been created in our middleware folder .

Does someone have an idea ?

Thank you

conditionally loading the Rollbar serviceprovider does not work with L.5.5's package auto discovery

Hi,
Using Laravel 5.5's auto package discovery will always load the Rollbar service provider. So if you want to conditionally load the Rollbar service for a specific environment as suggested in the docs this will not work.
Solution : add the Rollbar package to the dont-discover list in composer.json
Perhaps this should be added to the docs.

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

Update readme

Can we flesh out the readme and remove the screenshot?

Telemetry support

Similar to telemetry in rollbar.js.

This needs to include the config options for enabling/disabling telemetry and scrubbing telemetry data.

Context Data

Context data doesn't seem to be working.

I've tried the following:

  1. \Log::error($e, ['avar' => 'abcdef11']);
  2. \Log::error($e, ['person' => ['avar' => 'abcdef11']]);

I see both exceptions are logged, but the context data is missing.

Critical: #690 E_ERROR: Call to a member function getStatus() on null when upgrading from 2.3.0 to 2.4.0 using Laravel 5.2

After our last composer update, rollbar/rollbar-laravel was upgraded from 2.3.0 to 2.4.0. Immediately following, Rollbar began reporting critical errors pertaining to RollbarServiceProvider.php

Here's the log entry:
production.ERROR: exception 'Symfony\\Component\\Debug\\Exception\\FatalErrorException' with message 'Call to a member function getStatus() on null' in /var/app/current/vendor/rollbar/rollbar-laravel/src/RollbarServiceProvider.php:50\nStack trace:\n#0 {main}

Forcing composer.json to 2.3.0 using "rollbar/rollbar-laravel": "2.3.0" and running composer update resolves the issue.

screen shot 2018-10-04 at 2 08 45 pm

For reference we're running Laravel Framework version 5.2.45 and PHP 5.6.24

Problem upgrading from v2.0 to v2.2

I tried upgrading from v2.0 to v2.2 via composer but received the following error:

$ composer require rollbar/rollbar-laravel
Using version ^2.2 for rollbar/rollbar-laravel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: rollbar/rollbar[v1.3.1, v1.0.1].
    - Can only install one of: rollbar/rollbar[v1.3.1, v1.0.1].
    - Can only install one of: rollbar/rollbar[v1.3.1, v1.0.1].
    - rollbar/rollbar-laravel v2.2.0 requires rollbar/rollbar ^1.3.1 -> satisfiable by rollbar/rollbar[v1.3.1].
    - Installation request for rollbar/rollbar-laravel ^2.2 -> satisfiable by rollbar/rollbar-laravel[v2.2.0].
    - Installation request for rollbar/rollbar (locked at v1.0.1) -> satisfiable by rollbar/rollbar[v1.0.1].


Installation failed, reverting ./composer.json to its original content.

So, I removed rollbar all together (and made sure I didn't have any other instances of rollbar, including old jenssegers packages installed) and reinstalled. That solved the issue. Just wanted to post this in case there's someone else who needs the fix.

rollbar-laravel 2.4 / Laravel 5.4 - Call to a member function getStatus() on null in vendor/rollbar/rollbar-laravel/src/RollbarServiceProvider.php:50

I'm not sure what changed here, but I'm now getting an error whenever a log event is triggered.

[2018-10-03 18:33:50] production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getStatus() on null in /Users/snipe/Sites/snipe-it/snipe-it/vendor/rollbar/rollbar-laravel/src/RollbarServiceProvider.php:50

In my AppServiceProvider.php, I have:

/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    $monolog = Log::getMonolog();
    $log_level = config('app.log_level');

    if (($this->app->environment('production'))  && (config('services.rollbar.access_token'))){
        $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
    }

    foreach ($monolog->getHandlers() as $handler) {
        $handler->setLevel($log_level);
    }
}

And when \Log::debug('foo'); is called, I get the above error on getStatus().

If I remove the Rollbar references in the AppServiceProvider, the error goes away.

Any ideas? I've cleared composer, etc.

[4.0] Logger cannot be created with cached Laravel config

When caching your Laravel configs using artisan config:cache the Rollbar logger breaks:

Unable to create configured logger. Using emergency logger. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Unresolvable dependency resolving [Parameter #0 [ <required> array $config ]] in class Rollbar\\RollbarLogger at vendor/laravel/framework/src/Illuminate/Container/Container.php:948)

The problem is in the stopping condition of the service provider: https://github.com/rollbar/rollbar-php-laravel/blob/master/src/RollbarServiceProvider.php#L93. getenv always returns NULL when a cached config exists (which is good). Therefore, the Rollbar token is received from the config using key logging.channels.rollbar.token. However, the access token is stored under a different config key: logging.channels.rollbar.access_token. The result is that stop() returns true and the Rollbar logger never gets registered in the service container.

A workaround is to also include the token key in the config array:

'rollbar' => [
    'driver' => 'monolog',
    'handler' => \Rollbar\Laravel\MonologHandler::class,
    'access_token' => env('ROLLBAR_TOKEN'),
    'token' => env('ROLLBAR_TOKEN'), // Temporarily due to Rollbar-Laravel bug.
    'level' => env('ROLLBAR_LEVEL')
]

v2.2.0 does not log errors to Rollbar

laravel/framework 5.4.36
rollbar/rollbar-php-laravel 2.2.0

As soon as I get the update for 2.2.0 nothing gets logged to Rollbar. If I revert back to 2.1, everything works fine.

[4.0.1] Rollbar not reporting for Laravel <= 5.5

In v3.0.4, the RollbarServiceProvider sets up an event listener on Laravel's logger to handle sending the log message on to Rollbar.

In v4.0.0, this event listener was removed, and instead the RollbarServiceProvider binds a new custom exception handler over Laravel's default one, and this custom exception handler is responsible for sending the log message on to Rollbar.

In v4.0.1, this custom exception handler was removed, but the event listener from v3.0.4 was not added back in, so I believe that right now, there is nothing in Laravel <= 5.5 that sends the log message on to Rollbar.

Laravel >= 5.6 still works since the rollbar channel that is setup reports the log message directly to Rollbar.

I would suggest bringing the event listener back, but I believe you'll also need to include a check on Laravel <= 5.5 vs Laravel >= 5.6, since I think the messages would get duplicated in >= 5.6.

Thanks,
Patrick

Composer can't find class

I did composer install rollbar/rollbar-laravel and added Rollbar\Laravel\RollbarServiceProvider::class to config/app.php. Composer downloaded all the dependencies, but the autoloader was not able to find the RollbarServiceProvider class.

The same steps work with jenssegers/rollbar and Jenssegers\Rollbar\RollbarServiceProvider::class.

Local vs Production environment

Laravel version: 5.3.31
Rollbar version: ^2.1
Local OS: Windows 10
Production OS: Windows 7
Local Php version: 7.0.9
Production Php version: 7.1.1
both environment created by using xampp.

Its working fine on local environment but not working in the production environment.

Variable errors in views are not reporting

Bug i've noticed in the past month or so. When there is a variable that doesn't exist in a view, it appears in the error log but is not reporting to Rollbar. Previously, it would report these types of issues.

  • Laravel Error Log:
    screen shot 2018-04-24 at 7 46 50 pm

  • Rollbar:
    screen shot 2018-04-24 at 7 48 10 pm

Installation issue

C:\xampp\htdocs\project> composer require rollbar/rollbar-laravel
Using version ^2.1 for rollbar/rollbar-laravel
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Can only install one of: rollbar/rollbar[v1.3.1, v0.18.2].
- Can only install one of: rollbar/rollbar[v1.3.1, v0.18.2].
- rollbar/rollbar-laravel v2.1.0 requires rollbar/rollbar ^1.3.1 -> satisfiable by rollbar/rollbar[v1.3.1].
- Installation request for rollbar/rollbar-laravel ^2.1 -> satisfiable by rollbar/rollbar-laravel[v2.1.0].
- Installation request for rollbar/rollbar (locked at v0.18.2) -> satisfiable by rollbar/rollbar[v0.18.2].

Installation failed, reverting ./composer.json to its original content.

Dynamically Add global Context

I am looking to add "global" context for logs in specific sections of the application. For example, During a job, I would like to dynamically change the context of what entity is being worked on. The context may change multiple timed within the same job.

Job Starts

foreach ($entities as $entity) {
Rollbar::setContext(['entity_id' => $entity->id]);

$entity->doSomething();
}

Job Ends

UPDATE: The main reason I need this is because we are logging warnings. We need the context of the entity on the warning log.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.