PHPDocumentor 2和PHP 7在Doctrine中带有opcache问题

时间:2022-10-23 08:40:22

Hopefully someone here knows a thing or 2 about this.

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

Short Question

I am running into an error using phpdoc on the command line, installed via pear on PHP 7.0.2. The error is:

我在命令行上使用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

How do I fix this error?

我该如何解决这个错误?

Details

Opcache is enabled and opcache.load_comments=1 is in my opcache.ini file, verified by using the commands: php -i | grep "Opcode" and php -i | grep "opcache" respectively. Within that .ini file I can verify that changes are loaded by checking enable and disable opcache via that file.

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

With that said, if I have opcache.load_comments=1 in my .ini file, why am I still getting this error?

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

Thanks!

5 个解决方案

#1


14  

I encountered the same problem while using the PHAR version of PHPDocumentor. The PHAR includes an obsolete version of Doctrine Annotations.

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

The older version of Annotations is referring to the opcache.load_comments setting in php.ini, which does not exist in PHP 7:

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

This has been fixed upstream in Annotations:

这已在Annotations的上游修复:

For now, using the composer version of PHPDocumentor by executing composer require --dev phpdocumentor/phpdocumentor resolved the problem for me.

现在,通过执行composer需要使用PHPDocumentor的作曲家版本--dev phpdocumentor / phpdocumentor解决了我的问题。

#2


7  

You can also use composer without manually switching vendors directory contents. Just use:

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

composer require doctrine/annotations

to have the latest version of doctrine/annotations (at least 1.2.5 solves the problem)

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

#3


7  

phpDocumentor 2.8.5 is the default version with Ubuntu 16.04. However, php7 support wasn't added until 2.9. I got it working by using the following on the command line:

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

If you installed phpDocumentor from pear, use the following to remove it:

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

sudo pear uninstall phpdoc/phpDocumentor

#4


4  

Thanks deepdivedylan for links. However, composer require --dev phpdocumentor/phpdocumentor did not solve my problem. But reading through the links and downloading doctrine annotations patch 1.2.5 worked fine. Just download archive and replace vendor/doctrine/annotations folder with its contents.

感谢deepdivedylan的链接。但是,作曲家需要--dev phpdocumentor / phpdocumentor并没有解决我的问题。但阅读链接和下载doctrine注释补丁1.2.5工作正常。只需下载存档并将vendor / doctrine / annotations文件夹替换为其内容即可。

#5


0  

You can download the latest version of phar from github releases .

您可以从github发行版下载最新版本的phar。

The link from website is to an older version of it.

网站链接是旧版本。

#1


14  

I encountered the same problem while using the PHAR version of PHPDocumentor. The PHAR includes an obsolete version of Doctrine Annotations.

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

The older version of Annotations is referring to the opcache.load_comments setting in php.ini, which does not exist in PHP 7:

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

This has been fixed upstream in Annotations:

这已在Annotations的上游修复:

For now, using the composer version of PHPDocumentor by executing composer require --dev phpdocumentor/phpdocumentor resolved the problem for me.

现在,通过执行composer需要使用PHPDocumentor的作曲家版本--dev phpdocumentor / phpdocumentor解决了我的问题。

#2


7  

You can also use composer without manually switching vendors directory contents. Just use:

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

composer require doctrine/annotations

to have the latest version of doctrine/annotations (at least 1.2.5 solves the problem)

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

#3


7  

phpDocumentor 2.8.5 is the default version with Ubuntu 16.04. However, php7 support wasn't added until 2.9. I got it working by using the following on the command line:

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

If you installed phpDocumentor from pear, use the following to remove it:

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

sudo pear uninstall phpdoc/phpDocumentor

#4


4  

Thanks deepdivedylan for links. However, composer require --dev phpdocumentor/phpdocumentor did not solve my problem. But reading through the links and downloading doctrine annotations patch 1.2.5 worked fine. Just download archive and replace vendor/doctrine/annotations folder with its contents.

感谢deepdivedylan的链接。但是,作曲家需要--dev phpdocumentor / phpdocumentor并没有解决我的问题。但阅读链接和下载doctrine注释补丁1.2.5工作正常。只需下载存档并将vendor / doctrine / annotations文件夹替换为其内容即可。

#5


0  

You can download the latest version of phar from github releases .

您可以从github发行版下载最新版本的phar。

The link from website is to an older version of it.

网站链接是旧版本。