Download the PHP package itsmill3rtime/sentry-laravel-5-7 without Composer
On this page you can find all versions of the php package itsmill3rtime/sentry-laravel-5-7. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download itsmill3rtime/sentry-laravel-5-7
More information about itsmill3rtime/sentry-laravel-5-7
Files in itsmill3rtime/sentry-laravel-5-7
Package sentry-laravel-5-7
Short Description Laravel integration for Sentry (https://sentry.io)
License Apache-2.0
Homepage https://sentry.io
Informations about the package sentry-laravel-5-7
Sentry for Laravel
Laravel integration for Sentry.
Laravel Version Compatibility
- Laravel
4.2.x
is supported until version0.8.x
(composer require "sentry/sentry-laravel:0.8.*"
) - Laravel
5.x.x
is supported in the most recent version (composer require sentry/sentry-laravel
)
Installation
Laravel 5.x
Install the sentry/sentry-laravel
package:
If you're on Laravel 5.4 or earlier, you'll need to add the following to your config/app.php
:
Add Sentry reporting to app/Exceptions/Handler.php
:
Create the Sentry configuration file (config/sentry.php
):
Add your DSN to .env
:
Note: If you use SENTRY_DSN
in your .env
it will overwrite the DSN value set in the config/sentry.php
file.
Laravel 4.x
Install the sentry/sentry-laravel
package on version 0.8.*
since it's the last version to support Laravel 4:
Add the Sentry service provider and facade in config/app.php
:
Create the Sentry configuration file (config/sentry.php
):
Lumen 5.x
Install the sentry/sentry-laravel
package:
Register Sentry in bootstrap/app.php
:
Add Sentry reporting to app/Exceptions/Handler.php
:
Create the Sentry configuration file (config/sentry.php
):
Testing with Artisan
You can test your configuration using the provided artisan
command:
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.
In the following example, we'll use a middleware:
Displaying the error ID
When something goes wrong and you get a customer email in your inbox it would be nice if they could give you some kind of identitifier for the error they are seeing.
Luckily Sentry provides you with just that by adding one of the following options to your error view.
This could look something like this in for example your resources/views/error/500.blade.php
:
This ID can be searched for in the Sentry interface allowing you to find the error quickly.
Using Laravel 5.6 log channels
To configure Sentry as a log channel add the following config to the channels
section in config/logging.php
:
After you configured the Sentry log channel you can configure your app to both log to a log file and to Sentry by modifiying the log stack:
Optionally you can set the logging level and if events should bubble on the driver:
Resolve name conflicts with packages also called Sentry
To resolve this you will need to create your own service provider extending ours so we can prevent naming conflicts.
You can then add this service provider to the config/app.php
.
Optionally if you want to use the facade you also need to extend / create a new facade.
And add that facade to your config/app.php
.
After you added your own service provider, running php artisan vendor:publish --provider="App\Support\SentryLaravelServiceProvider"
publishes the Sentry config file to your chosen name (in the example above config/sentry-laravel.php
) preventing conflicts with a config/sentry.php
config file that might be used by the other package.
If you followed the regular installation instructions above (you should), make sure you replace app('sentry')
with app('sentry-laravel')
.
The namespace \App\Support
can be anything you want in the examples above.
Note: If you are on Laravel 5.5+ the Sentry package is probably auto discovered by Laravel, to solve this add or append to the extra
section in your composer.json
file and run composer update/install afterwards:
Contributing
Dependencies are managed through composer:
Tests can then be run via phpunit:
Community
- Bug Tracker
- Code
- Mailing List
- IRC (irc.freenode.net, #sentry)