当前位置: 首页 > 工具软件 > PhpDocumentor > 使用案例 >

phpDocumentor2的正确安装和使用方法

施喜
2023-12-01

缘起

本来我对phpdocumentor2(以下简称doc2)是拒绝的,想用doxygen来着。然而不知为何doxygen无法安装,遂转而去用doc2。 doc2生成的文档还是相当漂亮的,然而安装是场噩梦。下面我们追溯一下噩梦情节。

通过pear安装

一切正常的安装流程

github上的readme文件给出了3种安装方式,我们选择最古典的pear方式 首先得安装pear,可以通过go-pear获得。怎么获得兹不赘述,我用的开发套件,里面有这个东西。总之认为pear已经安装好了。 于是执行readme里面的代码

pear channel-discover pear.phpdoc.org

然而会报错,说是没这个东西,path的问题,找不到 于是切换到安装目录再执行,还是没有,于是只好这样

.\pear channel-discover pear.phpdoc.org

OK,频道已注册 看一眼都有哪些版本

.\pear remote-list -c phpdoc

目前只有一个版本,2.8.5。于是安装

.\pear install phpdoc/phpDocumentor 

下载正常,网速较快的话秒下,网速慢的话,可以去泡杯咖啡(并不是!)

奇葩的安装方式,本文重点

实际上下载完了我这里出现了错误:无法解包phpDocumentor-2.8.5.tgz 用7z解包,正常,解压出一个phpDocumentor-2.8.5.tar和一个package.xml。压缩包没有损坏。见了鬼。 于是百度,毫无意外,百度很和谐,边都不沾。 于是google——前提是改了hosts文件。 google给出了一个链接,不意外,是stackoverflow上面的讨论。上面采纳的答案是这样的

pear install --nocompress phpdoc/phpDocumentor

这回可以去泡咖啡了? 并不能.下载的文件是个phpDocumentor-2.8.5.tar包,依旧无法解包. 于是往下看,看到最后,别人这样说:

My solution for phpDocumentor 2.8.5 was 1.Download the tarball archive from https://github.com/phpDocumentor/phpDocumentor2/releases 2.Uncompress the archive phpDocumentor-2.8.5.tgz manulay (e.g. with 7zip) You will get the phpDocumentor-2.8.5.tar, uncompress it too and you will get the folder phpDocumentor-2.8.5 and the file package.xml 3.Edit the archive package.xml and change the text template:init to template_init (line 2036) in fact it is a path (Info source: https://github.com/phpDocumentor/phpDocumentor2/issues/1608) 4.Compress the folder phpDocumentor-2.8.5 and the file package.xml (e.g. phpdoc285.tar) 5.Install the archive phpdoc285.tar pear install --nocompress phpdoc285.tar

觉得靠谱,于是照做.于是成功了 归纳下来是这样

  1. 把刚才那个phpDocumentor-2.8.5.tar解包得到目录phpDocumentor-2.8.5和文件package.xml
  2. 修改里面的package.xml,将2036行的template:init改为template_init
  3. 把目录phpDocumentor-2.8.5和文件package.xml重新打包为phpdoc285.tar
  4. 执行命令
pear install --nocompress phpdoc285.tar

终于可以去泡咖啡了! 并不能:joy:

正确运行

readme分明写着

phpdoc run -d <SOURCE_DIRECTORY> -t <TARGET_DIRECTORY>

自然是不行的,依旧要找到安装目录并且.\

.\phpdoc run -d <SOURCE_DIRECTORY> -t <TARGET_DIRECTORY>

然而抛出如下错误:

Could not open input file: \phpdoc

WTF! google来到毫不陌生的stackoverflow,去粗取精后,得到如下solution 编辑器打开phpdoc.bat

@echo off
if "%PHPBIN%" == "" set PHPBIN=php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "%PHP_PEAR_BIN_DIR%\phpdoc" %*

把最后一行简单粗暴的改为

"%PHPBIN%" "phpdoc" %*

问题终获解决,现在可以抽支烟压压惊了..... 并不能!!! 不出意外的话,当你乐滋滋的盯着美观大方的powershell,犹豫着是先抽烟还是先喝咖啡的时候,如你所料,又TM出错了.

Execute transformation using writer "Graph" Unable to find the dot command of the GraphViz package. Is GraphViz correctly installed and present in your path?

不过不要紧,这东西是画图表用的,用得着就装上,用不着就算逑.本文到此为止.

转载于:https://my.oschina.net/inuxor/blog/613315

 类似资料: