phpdocumentor2 简介安装使用详解

来源:互联网 发布:德州金蝶软件 编辑:程序博客网 时间:2024/06/01 12:19
官网http://www.phpdoc.org/
项目地址https://github.com/phpDocumentor/phpDocumentor2
首先来个翻译点官网简介:
===============================================================================

【phpDocumentor an application that is capable of analyzing your PHP source code and DocBlock comments to generate a complete set of API Documentation.】

phpDocumentor 2是一个可以 分析php源代码和注释块并生成文档的程序

Inspired by phpDocumentor 1 and JavaDoc it continues to innovate and is up to date with the latest technologies and PHP language features.

基于phpdocumentor1和javadoc启发而来,它持续创新的使用了一些新技术和支持php的新特性。

phpdocumentor2的特点:

  • 兼容php5.3,全面支持命名空间和闭包等。【PHP 5.3 compatible, full support for Namespaces, Closures and more is provided.】
  • 识别支持任何tag,以及一些追加的 (比如 @link). 【tagShows any tag, some tags add additional functionality to phpDocumentor (such as @link).】
  • 更快的处理速度。 较  phpDocumentor 1在Zend Framework 下的处理耗时有了明显的减少【Processing speed, Zend Framework experienced a significant reduction in processing time compared to phpDocumentor 1.】
  • 低内存消耗,小中大型工程的内存消耗分别低于20MB,40MB和100MB【Low memory usage, peak memory usage for small projects is less than 20MB, medium projects 40MB and large frameworks 100MB.】
  • 增量解析。如果你有之前运行phpdoc获得的structure.xml文件,那么小修改后重新生成文档的速度将提升80%。【Incremental parsing, if you kept the Structure file from a previous run you get an additional performance boost of up to 80% on top of the mentioned processing speed above.】
  • 简单就能创建模板,只需1小步和编辑3个文件。【Easy template building, if you want to make a branding you only have to call 1 task and edit 3 files.】
  • 兼容1代的命令行。例如 --directory, --file and --target 【Command-line compatibility with phpDocumentor 1, phpDocumentor 2 is an application in its own right but the basic phpDocumentor 1 arguments, such as --directory, --file and --target, have been adopted.】
  • 两步式处理。首先生成structure文件,你可以根据这个文件来格式化相关信息,用自己的工具来展现信息!【Two-step process, phpDocumentor first generates a cache with your application structure before creating the output. If you'd like you can use that to power your own tools or formatters!】

安装需求:
  • PHP 5.3.3 or higher
  • ext/iconv, http://php.net/manual/en/book.iconv.php (is enabled by default since PHP 5.0.0)
  • ext/intl, http://php.net/manual/en/book.intl.php
  • The XSL extension, http://www.php.net/manual/en/book.xsl.php (可选,只在使用xsl的模板时使用optional, only used with XSL based templates) 
  • Graphviz (可选,用来生成类图optional, used for generating Class diagrams)

Note: If you do not want to install the Graphviz dependency you are encouraged to generate your own template and make sure that it does not contain anything related to Graph. An easier solution might be to editdata/templates/responsive/template.xml file and remove every line containing the word Graph but this will be undone with every upgrade of phpDocumentor.

Please see the documentation about creating your own templates for more information.

提醒:如果你不想安装Graphviz相关依赖项,建议你自己制作无关graph的模板。简单的方法是编辑data/templates/responsive/template.xml 文件并且移除所有包含graph这个词的行。但是每当phpDocumentor升级,将会被还原。建议你查看文档来制作你自己的模板。(yukon12345:其实不安装graphviz也可以,就是不能生成类图)

===============================================

翻译结束


1安装graphviz
这个虽然是可选项,但是对于工程里的复杂类关系非常有用,因此要首先安装。
但是要把graphviz安装成功,还是需要一点注意:
安装时候将路径设为无空格的,比如d:/graphviz就可以,然后手动把bin目录加入系统环境变量path中
在cmd窗口下输入dot后如果不报错说明graphviz才算真的安装完全。
2.安装PEAR
低版本的php一般都会有go-pear的批处理文件自动安装pear,
而5.4版本没有go-pear,到http://pear.php.net/go-pear.phar 下载文件,cmd cd到php目录执行php go-pear.phar  安装
如果出现**ERROR **  Please, enter the php.exe path,
那么考虑第12项 path to CLI php.exe,输入12后会弹出浏览框选择好即可,同时注意检查第11项的路径。
如果装完PEAR总报路径错误查看此处 http://blog.csdn.net/yukon12345/article/details/11533455
3.之后安装phpdoc。
5.3.3以上的用
pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor
低版本的php最好使用
pear install PhpDocumentor 
来安装相适应的版本
4.测试及说明
装好之后命令行执行phpdoc,如果有相关提示ok就说明安装成功,同时php文件夹下有一个phpdoc.bat的文件
phpdoc生成文档有2步,第一步是解析源文件,生成含抽象语法树的structrue.xml文件,
再由structure文件转换成一种可读文件。
5.使用
最简单的用法是
phpdoc -d [SOURCE_PATH] -t [TARGET_PATH]
d代表路径directory,t代表target。或者可以选择-f来指定单个文件
制定好路径稍等片刻执行完毕就可以在target文件夹里看到说明文档了
如果执行是出现
 Unable to find the `dot` command of the GraphViz package. Is GraphViz correctly installed and present in your path?
说明Graphviz没有安装,谷歌之,phpdoc管理者也没有很好的解释,只是说升级一下phpdoc和pear
不过下面这篇作者说的不错
http://www.cnblogs.com/WestContinent/archive/2013/03/19/2970231.html
经历一系列折腾后,终于可以完美使用phpdocmentor咯

原创粉丝点击