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.

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

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统