You find your DSN in your Sentry account under "Client Keys" in your project settings.
When you have located the DSN copy it and add it to your .env
file like this:
SENTRY_LARAVEL_DSN=YOUR_SENTRY_DSN_HERE
To handle unhandled errors you also need to put this in your App/Exceptions/Handler.php
:
public function register()
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
You probably already have a register
method there. If it empty you should replace it with this. If you have something there you probably have to merge this register
with your current one. If you want help with that, post your current register
method here.
After this php artisan sentry:test
should work. You might have to clear the cache if you have config cache turned on in your environment (php artisan config:clear
). After you have verified that is works you should probably remove the DSN from you .env
in your local environment and add it to your production and staging environments if you have any.
Here is a link to the Sentry documentation: https://docs.sentry.io/platforms/php/guides/laravel/
I would also recommend that you enable performance monitoring. It is a great feature!