phpDocumentor - 无法打开输入文件:phpdoc.php


phpDocumentor - Could not open input file: phpdoc.php

我正在尝试使用phpDocumentor(第一次,我不知道我在做什么)。实际上,我只想将其与SublimeText 2和此插件一起使用。你能一步一步地指导我应该怎么做才能让它工作吗?这是我现在所做的:(我使用的是Windows 7)从这里下载了phpDocumentor并将其放置在某个地方。我已经为phpdoc/bin创建了系统PATH(所以phpdoc.bat可以通过sublime插件执行),然后还将系统路径添加到php(来自WAMPserver安装)

当我尝试使用我的插件(或在控制台窗口中执行phpdoc)时,出现此错误:

Could not open input file: 'phpdoc.php

运行:

pear

它会为你设置%PHP_PEAR_PHP_BIN%

你需要将

"PHP_PEAR_BIN_DIR"的环境路径设置为"phpdoc.php"所在的目录。

我已经更改了phpdoc.bat文件以指向phpdoc的确切位置.php

@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%" "C:'wamp'bin'php'php5.3.10'phpdoc.php" %*

在我的 Windows 7 系统上,我在 wamp 中设置了 phpDocumentor(版本 2.6.1),我的路径如下:

D:'Projects'wamp'www'phpDocumentor
D:'Projects'wamp'www'phpDocumentor'bin 

现在我所做的是编辑位于 path 的phpdoc.bat文件:

D:'Projects'wamp'www'phpDocumentor'bin'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%" "D:'Projects'wamp'www'phpDocumentor'bin'phpdoc" %*

因此,我用新代码"%PHPBIN%" "phpdoc" %*编辑了"%PHPBIN%" "%PHP_PEAR_BIN_DIR%'phpdoc" %*的最后一行。之后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%" "phpdoc" %*

此后,我再次在cmd中运行以下命令:

D:'Projects'wamp'www'phpDocumentor'bin>phpdoc

输出是这样的:

D:'Projects'wamp'www'phpDocumentor'bin>phpdoc
Collecting files .. OK
Initializing parser .. OK
Parsing files
  [Exception]
  No parsable files were found, did you specify any using the -f or -d parame
  ter?
project:run [-t|--target[="..."]] [-f|--filename[="..."]] [-d|--directory[="..."
]] [--encoding[="..."]] [-e|--extensions[="..."]] [-i|--ignore[="..."]] [--ignor
e-tags[="..."]] [--hidden] [--ignore-symlinks] [-m|--markers[="..."]] [--title[=
"..."]] [--force] [--validate] [--visibility[="..."]] [--defaultpackagename[="..
."]] [--sourcecode] [-p|--progressbar] [--template[="..."]] [--parseprivate] [--
log[="..."]]
D:'Projects'wamp'www'phpDocumentor'bin>

因此,输出显示它已成功运行!

PHP的include_path将需要包含该phpdoc.php文件的目录的路径。 否则,使用具有相对路径的require/include语句的phpDocumentor代码将无法找到任何内容。

我刚刚在Windows 7上通过PEAR安装了phpDocumentor2。我发现跑步:

phpdoc -d . -t docs

提升的命令提示符下完成了这个技巧 - 我怀疑我的机器上仍然存在一些 PATH 问题,但已经完成了 PEAR 和 phpDocumentor 的所有默认安装步骤,它已被证明是我发现的最快的解决方法。

我收到相同的错误消息,已经做出的答案将我带到了正确的道路上。

由于我不使用 wamp/xampp 或任何这些程序,我想:为什么不直接用 PHP 运行它呢?

我已经通过WebPI在全球范围内安装了PHP7.0.x。

只需要在命令上加上前缀php,一切正常:

php .'phpDocumentor'bin'phpdoc -d .'src' -t .'dst'