drozwmi5440 2010-04-24 18:54
浏览 22
已采纳

用于编码php库的框架? [关闭]

there are plenty of frameworks for coding MVC web applications.

this time im going to code a library (think of Doctrine or Solr) with a bunch of class files. u just include a bootstrap or a class file and you are ready to use my classes.

i have never tried to code a library before and intend to code one for learning purpose so that i can use various design patterns i have learned.

are there any great frameworks for this, how i should organize the different class files, where i can put configuration files and so on?

tutorials or other information would be great too.

thanks

UPDATE: its just in general, not something specific. im wondering if there is a "pattern" just like for web applications (MVC): should it be one file he includes and that file will include all other class files? should it be a class file he includes or a so called bootstrap file? in short, i need to know how to code a library so every developer could use it the open source way

  • 写回答

2条回答 默认 最新

  • doukan5332 2010-04-25 00:51
    关注

    Library code covers so many diverse areas that it's hard to imagine a general framework for library development.

    Generally speaking, you should strive to create a library that is (among other things):

    • Consistent - Your library's API should be as consistent as possible. For example: do you pass standard argument lists to constructors, or a single $config array containing name/value pairs? If you favor factory methods, implement them consistently across the whole library.

    • Efficient - avoid loading classes that aren't needed. Figure out how to manage dependencies - don't just load every class from some central bootstrap script. Consider a directory structure like that used by PEAR or Zend Framework. This can help you integrate with various autoloaders that your users may already be using.

    • Testable - a library with good tests that cover it is more valuable than one without.

    • Documented - Get cozy with PHPDocumentor, and be prepared to write additional documentation that is heavy on example client code.

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog