douweibiao8471 2012-04-25 15:17
浏览 23
已采纳

捕获生产环境中的所有应用程序异常和PHP错误

How can I catch all application exceptions and PHP errors in production environment?

I am using a custom MVC framework, and I have a entry point where my MVC framework starts. So I already wrap this entry point with a general:

 try{
    //start point of mvc framework that load main class 
    //that manage request, response, route etc
 }catch(Exception $e) {
    //return response 404 to client if something goes wrong
 }

Is this enough? What about PHP errors?

It's a production environment so I don't the users to see the errors, but I want to log all for debugging. Is there an opensource PHP class that log errors in a elegant way that I can inspire from?

  • 写回答

1条回答 默认 最新

  • douhui5529 2012-04-25 22:00
    关注

    Nope, an exception handler is not enough. You should also transform php notices/errors/warnings into exceptions so that you can catch them as well, I have an example here: http://codehackit.blogspot.com/2012/01/php-errorswarningsnotices-to-exceptions.html Unfortunately most of PHPs built in functions still don't throw exceptions but these couple lines fix that ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100