dourukeng5302 2011-11-18 11:50
浏览 19
已采纳

在PHP中组织/使用可重用的代码库[关闭]

My goal is to write some reusable (OO) code for communicating with an external API, but as I'm not well versed in this kind of stuff in PHP, I'm not sure what is the best way to organize and load my code.

Stuff like limiting the amount of knowledge the client code needs to have about the libraries classes and making sure there are no naming collisions has led me to experiments with namespacing and avoiding having to inlude all the library files have led to experiments with autoloading, but I have so many questions on the subject that in stead of a lengthy process of trial and error, I thought I'd see if I anyone here possessed some wisdom on the subject.

So I guess my main questions are:

  • How to best encapsulate the library code, making it stand on it's own as much as possible.
  • How to best load/call this library code from the client code.

... but feel free to expand on whatever you think should be considered. :)

  • 写回答

2条回答 默认 最新

  • douhuan1905 2011-11-18 12:15
    关注

    The best way to go about it is simply to check how others do it Both Zend Framework and Symfony for instance will have a clear separation between these two. May not be a bad idea to borrow some concepts and make them your own.

    I tend to simply put my library code and 'client code' in separate namespaces.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错