PHP 7 和 PHPDocumentor 安装

use*_*540 6 php7

我已经安装PHP7,pearphpdocumentor. 在安装过程中一切看起来都很好,但是当我运行时,phpdoc我收到以下错误。

PHP Fatal error:  Uncaught Doctrine\Common\Annotations\AnnotationException: You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1. in /usr/share/php/phpDocumentor/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:193

PEAR Version: 1.10.1
PHP Version: 7.0.9-1+deb.sury.org~trusty+1
Zend Engine Version: 3.0.0
Running on: Linux kevin-lt 3.13.0-46-generic #76-Ubuntu SMP Thu Feb 26
18:52:13 UTC 2015 x86_64

phpDocumentor: 2.8.5
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?

小智 6

如果您查看 Pear 包https://pear.phpdoc.org/,您会注意到官方包是基于 2.8.5 版本的。此版本不支持 PHP7.0 语法。

该项目已于 5 月发布了 2.9.0 版本,如果您想安装它,您需要从 Github 获取该版本。例如(进入发布选项卡以获得最后一个):

wget https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar
Run Code Online (Sandbox Code Playgroud)

然后,您需要遵循手册(使用 PHAR,除了您将 phpdoc.org 中的一个替换为 Github 中的一个)

  1. http://phpdoc.org/phpDocumentor.phar或从 github 上列出的版本下载 phar 文件
  2. 使用 sudo 将文件移动到您的 bin 目录: sudo mv phpDocumentor.phar /usr/local/bin/phpdoc
  3. 确保文件具有执行权限:sudo chmod +x /usr/local/bin/phpdoc 通过phpdoc --version从任何目录运行来确认它运行(如果您首先远程连接,则可能需要重新启动 SSH 会话)。