0

I am looking for a free for commercial use PHP library to help me with error handling.

Ideally (but not a “must”), it should hook error and exception handling, so that I just add one line of code to kick it off.

It would be nice if I could override it in a few places, but continue to have it as the default handler. Possibly just off() and on() calls.

It should gather as much information as possible, and present it in a clear manner. E.g file name, line number, error/exception info, stack dump, globals such as $_POST[], $_GET[], etc, local variables if that is possible, and the kitchen sink.

It should be possible to control how the information is presented. For instance, during development, I might want to see it in the browser (or its developer console). In production, I would probably want it to email me, and possibly inform the user that a problem has occurred and is being handled, maybe providing a link with more info.


[Update] I would also like something similar for Python. My current exception handler looks like this (not any more it doesn't; see the link just before):

# +=+=+=+=+=+=+=+=+=+=+=+=+=
except KeyboardInterrupt as e: # Ctrl-C
    raise e
except SystemExit as e: # sys.exit()
    raise e
except Exception as e :
    exc_type, exc_obj, exc_tb = sys.exc_info()
    scriptName = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
    functionName = inspect.currentframe().f_code.co_name
    print('=======================================================================================================')
    print('Unhandled exception: ', exc_type, scriptName, 'at line', exc_tb.tb_lineno)
    print('                      in function', functionName)
    print('                     ', str(e))

    traceback.print_exc()
    sys.exit(1)
3
  • I can't believe that there are no other PHP coders here. What do you use? – Mawg says reinstate Monica Apr 16 '19 at 7:35
  • 1
    Coders are probably in stackoverflow. Did you try the try,catch, and throw commands built in to php? – cybernard Apr 16 '19 at 16:40
  • But software recommendations are off topic there :-) There are enough if us here, too. Yes, I catch exceptions, also for some error conditions, I have a central error handler. I send myself en email with stack dump & error details, but was looking for something more "professional". I found some stuf fon GitHib after posting this. See github.com/… – Mawg says reinstate Monica Apr 16 '19 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.