Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sentry: How to configure sentry in php?

Tags:

php

sentry

This is for Sentry (Open-source error tracking) users.

I have tried some code, but I don't get success. I hope you could look into this.

Thanks to everyone in advance.

I have download the SDK zip and upload it on servers. Well, I have read from some stuff for autoloader and raven_client but still, I don't find autoloder.php.

I am using sentry/sdk:2.0.3

require_once 'sentry-php-master/src/Sdk.php';

Sentry\init(['dsn' => '___DSN___' ]);

throw new Exception("My first Sentry error!");

I am expecting it works and I can trace the errors.

like image 405
Bhargav Dave Avatar asked Nov 07 '22 14:11

Bhargav Dave


1 Answers

Why aren't you using composer ?

Composer solves a number of problems including dependency resolution for PHP packages, keeping all packages updated and another benefit of using composer is autoloading.

I would suggest the following approach:

  1. composer require sentry/sdk:2.1.0 in your project's root directory.
  2. require_once __DIR__ . '/vendor/autoload.php';
  3. Connect the SDK to Sentry

    Sentry\init(['dsn' => 'https://[email protected]/18xxx47']);

Lastly, verify your setup by triggering a PHP exception by throwing one as you've already done with throw new Exception("My first Sentry error!");

Docs

like image 134
adoubleyoueye Avatar answered Nov 14 '22 21:11

adoubleyoueye