dongshi6528 2009-09-21 01:46
浏览 42
已采纳

PHP 5 - 使用cURL / socket调用解耦重要脚本,好主意? [关闭]

I have an IPN script for PayPal, and as I can only rely on a log file to debug it and it's hard to maintain a testing server (and to test even for I am a one-man team), I am considering using cURL to run other scripts which would handle sending of emails, logging into database and updating of logs.

This way, if I have to send a new email (for some reason, clients never made up their mind), I don't have to tangle with the IPN script. Not just that, if for some reasons those new additions cause a FATAL error, the original IPN still runs. Is this a good idea?

  • 写回答

1条回答 默认 最新

  • doukuang1897 2009-09-21 02:10
    关注

    Why chew up valuable apache processes (assuming apache/mod_php)?

    If you want to do things asynchronously, cURL won't help, since it doesn't operate like that. You might look at kicking off some external scripts via the command line, if you want to do some things in a fire-and-forget sort of way.

    Otherwise, what's wrong with just abstracting this peripheral (to IPN handling) activity like you would any other abstraction? Wrapping it in a function being the most obvious thing.

    Then if you need to add some new feature (sending a new kind of email, for example), you just write a function that sends that email, test it until it works, then add a single line to your IPN-handling script.

    Maybe I'm missing something?

    Responding to your edit: Obviously, you should avoid fatal errors at all costs. But you should be able to avoid them without resorting to these kinds of heroics. For example, if you need to send an email, then write a function to send it based on some parameters. Ensure that function won't create fatal errors by writing enough test coverage.

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

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考