PHPDocumentor 2和PHP 7与Doctrine中的opcache问题

Pau*_*ton 14 php phpdoc opcache phpdocumentor2 php-7

希望有人在这里知道一件事或两件事.

简短的问题

我在命令行上使用phpdoc遇到错误,在PHP 7.0.2上通过pear安装.错误是:

#> 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/local/php5-7.0.2-20160108-102134/lib/php/phpDocumentor/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:193
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个错误?

细节

Opcache已启用并opcache.load_comments=1位于我的opcache.ini文件中,分别使用命令:php -i | grep "Opcode"和验证php -i | grep "opcache".在该.ini文件中,我可以通过检查启用并通过该文件禁用opcache来验证是否加载了更改.

话虽如此,如果我opcache.load_comments=1在我的.ini文件中,为什么我仍然会收到此错误?

谢谢!

dee*_*lan 15

我在使用PHAR版本的PHPDocumentor时遇到了同样的问题.PHAR包括一个过时的Doctrine Annotations版本.

旧版本的Annotations指的是PHP 7中不存在的opcache.load_comments设置php.ini:

这已在Annotations的上游修复:

就目前而言,使用PHPDocumentor的作曲家版本通过执行composer require --dev phpdocumentor/phpdocumentor解决了我的问题.


Grz*_*uze 8

您也可以使用composer而无需手动切换供应商目录内容.只需使用:

composer require doctrine/annotations
Run Code Online (Sandbox Code Playgroud)

拥有最新版本的doctrine/annotations(至少1.2.5解决了这个问题)


小智 7

phpDocumentor 2.8.5是Ubuntu 16.04的默认版本.但是,直到2.9才添加php7支持.我在命令行中使用以下命令:

sudo apt-get install php7.0-mbstring
wget https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar
chmod +x phpDocumentor.phar
sudo mv phpDocumentor.phar /usr/local/bin/phpDocumentor-2.9.phar
sudo ln -s /usr/local/bin/phpDocumentor-2.9.phar /usr/local/bin/phpdoc
Run Code Online (Sandbox Code Playgroud)

如果您从pear安装了phpDocumentor,请使用以下命令将其删除:

sudo pear uninstall phpdoc/phpDocumentor
Run Code Online (Sandbox Code Playgroud)