2017 © Pedro Peláez
 

library sentry-laravel

Laravel integration for Sentry (http://getsentry.com)

image

rsands2801/sentry-laravel

Laravel integration for Sentry (http://getsentry.com)

  • Friday, March 17, 2017
  • by rsands2801
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 67 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

sentry-laravel

Laravel integration for Sentry., (*1)

Laravel 5.x

Install the sentry/sentry-laravel package:, (*2)

$ composer require sentry/sentry-laravel

Add the Sentry service provider and facade in config/app.php:, (*3)

'providers' => array(
    // ...
    Sentry\SentryLaravel\SentryLaravelServiceProvider::class,
)

'aliases' => array(
    // ...
    'Sentry' => Sentry\SentryLaravel\SentryFacade::class,
)

Add Sentry reporting to app/Exceptions/Handler.php:, (*4)

public function report(Exception $exception)
{
    if ($this->shouldReport($exception)) {
        app('sentry')->captureException($exception);
    }
    parent::report($exception);
}

Create the Sentry configuration file (config/sentry.php):, (*5)

$ php artisan vendor:publish --provider="Sentry\SentryLaravel\SentryLaravelServiceProvider"

Add your DSN to .env:, (*6)

SENTRY_DSN=https://public:secret@sentry.example.com/1

Laravel 4.x

Install the sentry/sentry-laravel package:, (*7)

$ composer require sentry/sentry-laravel

Add the Sentry service provider and facade in config/app.php:, (*8)

'providers' => array(
    // ...
    'Sentry\SentryLaravel\SentryLaravelServiceProvider',
)

'aliases' => array(
    // ...
    'Sentry' => 'Sentry\SentryLaravel\SentryFacade',
)

Create the Sentry configuration file (config/sentry.php):, (*9)

$ php artisan config:publish sentry/sentry-laravel

Lumen 5.x

Install the sentry/sentry-laravel package:, (*10)

$ composer require sentry/sentry-laravel

Register Sentry in bootstrap/app.php:, (*11)

$app->register('Sentry\SentryLaravel\SentryLumenServiceProvider');

# Sentry must be registered before routes are included
require __DIR__ . '/../app/Http/routes.php';

Add Sentry reporting to app/Exceptions/Handler.php:, (*12)

public function report(Exception $e)
{
    if ($this->shouldReport($e)) {
        app('sentry')->captureException($e);
    }
    parent::report($e);
}

Create the Sentry configuration file (config/sentry.php):, (*13)

<?php

return array(
    'dsn' => '___DSN___',

    // capture release as git sha
    // 'release' => trim(exec('git log --pretty="%h" -n1 HEAD')),

    // Capture bindings on SQL queries
    'breadcrumbs.sql_bindings' => true,

    // Capture default user context
    'user_context' => true,
);

Adding Context

The mechanism to add context will vary depending on which version of Laravel you're using, but the general approach is the same. Find a good entry point to your application in which the context you want to add is available, ideally early in the process., (*14)

In the following example, we'll use a middleware:, (*15)

namespace App\Http\Middleware;

use Closure;

class SentryContext
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure                 $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (app()->bound('sentry')) {
            /** @var \Raven_Client $sentry */
            $sentry = app('sentry');

            // Add user context
            if (auth()->check()) {
                $sentry->user_context([...]);
            } else {
                $sentry->user_context(['id' => null]);
            }

            // Add tags context
            $sentry->tags_context([...]);
        }

        return $next($request);
    }
}

Contributing

First, make sure you can run the test suite. Install development dependencies :, (*16)

$ composer install

You may now use phpunit :, (*17)

$ vendor/bin/phpunit

Resources

The Versions

17/03 2017

dev-releases/0.4.x

dev-releases/0.4.x http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

22/02 2017

dev-master

9999999-dev https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Richard Sands

laravel logging errors sentry

09/02 2017

dev-releases/0.6.x

dev-releases/0.6.x https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

09/02 2017

0.6.1

0.6.1.0 https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

24/01 2017

0.6.0

0.6.0.0 https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

09/12 2016

dev-releases/0.5.x

dev-releases/0.5.x https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

09/12 2016

0.5.0

0.5.0.0 https://sentry.io

Laravel integration for Sentry (https://sentry.io)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

30/09 2016

0.4.1

0.4.1.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

30/09 2016

0.4.0

0.4.0.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

06/05 2016

0.3.0

0.3.0.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

04/05 2016

0.2.0

0.2.0.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

27/04 2016

0.1.1

0.1.1.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry

27/04 2016

0.1.0

0.1.0.0 http://getsentry.com

Laravel integration for Sentry (http://getsentry.com)

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

laravel logging errors sentry