0

What's the best way to add email notifications for CakePHP crashes? I want to be emailed with a stacktrace whenever a fatal error occurs, so that I can know immediately instead of checking the logs.

I looked at overriding AppController::appError(); but I don't want to replace all of the exception handling.

erjiang
  • 44,417
  • 10
  • 64
  • 100
  • You've probably already considered this, but could you create `AppController::appError();` with the email code and then just call `parent::appError();`? – ahjohnston25 Jul 11 '13 at 18:51
  • http://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-error – Alex Stallen Jul 11 '13 at 19:01
  • @ahjohnston25 I vaguely remember there being another hook that was better for this, but I can't find it now. – erjiang Jul 11 '13 at 20:04

1 Answers1

1

Check this out, it is to long to paste here.

https://github.com/CakeDC/utils/blob/develop/Error/EmailErrorHandler.php

It is a customized error handler for CakePHP. You need to configure CakePHP to use that error handler class. My pull request to the core was rejected that introduced an Event in the handleError() method... An event there would make it really easy to handle use cases like this.

floriank
  • 25,546
  • 9
  • 42
  • 66