integration (in Expressive)

Hello everyone,

I would like to integrate Sentry to my Expressive application and wonder what would be the best way to do this ?

I found stickeeuk/zend-expressive-sentry (and its forks) but it uses an outdated version of the “Sentry PHP package” ; so this is not really an option.
The last version is here:

My idea was just to create a new Middleware that would initiate Sentry but it doesn’t work (and was probably just a - too - naive way to do this).

If I could just initiate Sentry, I would already be more than happy but I think it would be even better if Sentry was only enable in “producation mode” (when $config['debug'] = false;) and have only Whoops enabled in “development mode” (when $config['debug'] = true;).

Does anyone have a idea on how to do this properly or could give me some tips ?
Thanks a lot :slight_smile:

Sentry is to be booted pre-middleware: it is not part of the request cycle, but rather the application boot sequence.

1 Like

Yes, that’s what I thought !

Thanks for the first clue :slight_smile:

I’ve had a simple library for this for a while. I just updated it with my local version.

1 Like

Awesome! :heart_eyes:

That looks REALLY close to what I was coding (based on outdated library).
I just have a question, but I’ll ask it directly on your repo!

There is also Monolog and a Sentry handler.

1 Like

I created 2 new libraries.

  1. geo6/zend-expressive-sentry
    Send the errors and exceptions (directly) to

  2. geo6/zend-expressive-monolog
    Add Monolog as ErrorHandler with support of

    • StreamHandler (send errors and exceptions to a file)
    • SentryHandler (send the errors and exceptions to

I’ll spend the next few days to test it properly.
Thank you all for the advice ; feedback is of course welcome!