is there a way to handle error reporting in a centralized manner in PHP? I'd like to be notified of all errors raised by my application by email.
What's the best way to achieve this for a whole application?
Thanks
As Kalium mentioned, you'll want to be using set_error_handler
, but that only gets you part of the way. You also want to trap uncaught exceptions. For that, use set_exception_handler
.
What I do myself is have my code trap errors, and convert those errors to approprate exceptions that I can catch elsewhere. For anything that isn't caught, I use the default exception handler to log and report them, and to display an appropriate error if necessary.