Help: Sentry and Codeigniter

I’ve been trying to get sentry to work with Codeigniter (a PHP framework) and I’m sad to say that I wasn’t able to find any upto date resource on how to do this.

What I’m trying to achieve:
I want to be able use sentries automatic error and exception capturing system in codeigniter in such a way that an error or exception should get logged from any controller/model in the entire application, without having to explicitly write code in every controller/model

Possible options:
I first tried to use the index.php in the Codeigniter root directory and adding the code snippet to it. But errors in the controllers aren’t caught that way. I then tried adding a pre_controller hook to run a php script with the code snippet but that also only logged errors in the script file.

Am I supposed to add the raven library in the constructor of the System/Core/Controller.php
Or and I forced to insert the code snippet in every controller of my application?
Will errors in the model also get logged If I have the sentry code snippet in the controller?

This repo: https://github.com/andrewryno/codeigniter-raven-php
was the only resource I code find and it’s very outdated. Nothing I’ve tried worked.

I was wondering if anyone has used Codeigniter with Sentry before and if yes, it would be great if you could point me in the right direction.

3 Likes

Also interested in how to use sentry for projects with Codeigniter!

1 Like

Hi,

I have a custom controller class and all the other controllers are extending this one.
I added the code snippet in the constructor of this class and so far it seems to be working.

1 Like

Anyone trying to implement this with CodeIgniter 4?

Is this working? Have someone tried it?