简体   繁体   English

无法在 Debian9 上使用 PHP7 启用 XMLWriter 模块

[英]Cannot enable XMLWriter module with PHP7 on Debian9

I am trying to install a PHP app that is using PHPSpreadSheet library.我正在尝试安装一个使用 PHPSpreadSheet 库的 PHP 应用程序。

Web server is Nginx; Web服务器是Nginx; OS is Debian 9.5 and current PHP-FPM version is 7.0.操作系统为 Debian 9.5,当前 PHP-FPM 版本为 7.0。

While trying to use PHPSpreadsheet library, I'm facing an error as below在尝试使用 PHPSpreadsheet 库时,我遇到了如下错误

Error: Class 'XMLWriter' not found错误:找不到类“XMLWriter”

File /var/www/XXXX/vendor/cakephp/cakephp/src/PhpOffice/PhpSpreadsheet/Shared/XMLWriter.php文件 /var/www/XXXX/vendor/cakephp/cakephp/src/PhpOffice/PhpSpreadsheet/Shared/XMLWriter.php

Line: 5线路:5

Digging a bit into the library itself, I see the class is trying to inherit from \\XMlWriter - which is a module described as mandatory for PHPSpreadsheet to work - til now I'm fine.深入研究库本身,我看到该类正试图从 \\XMlWriter 继承 - 这是一个被描述为 PHPSpreadsheet 工作必需的模块 - 直到现在我很好。

<?php

namespace Cake\PhpOffice\PhpSpreadsheet\Shared;

class XMLWriter extends \XMLWriter
{
...

Issue is that I already installed php7.0-xml on my Debian (also restarded Nginx) but it seems XMLWriter is still not installed and thus generating this fatal error...问题是我已经在我的 Debian(也重新启动了 Nginx)上安装了 php7.0-xml 但似乎 XMLWriter 仍未安装,因此产生了这个致命错误......

See below output from apt请参阅下面的 apt 输出

apt-get install php7.0-xml
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-xml is already the newest version (7.0.30-0+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Also, in my phpinfo file, I cannot find any other reference to XMLWriter than the one displayed author names.此外,在我的 phpinfo 文件中,除了显示的作者姓名之外,我找不到任何其他对 XMLWriter 的引用。 This module is definitly not enabled!这个模块绝对没有启用!

Is there any other step I need to run to really enable this module in PHP environment?我还需要运行其他任何步骤才能在 PHP 环境中真正启用此模块吗?

Edit: I also had to install php7.0-gd and php7.0-zip;编辑:我还必须安装 php7.0-gd 和 php7.0-zip; for those 2 modules, I ran apt-get install php7.0-gd php7.0-zip and service php7.0-fpm restart to see them active with my phpinfo()对于这两个模块,我运行apt-get install php7.0-gd php7.0-zipservice php7.0-fpm restart以查看它们与我的 phpinfo()

Everything seems normal for those modules as I can see ini files in /etc/php/7.0/fpm/mods-available这些模块的一切似乎都很正常,因为我可以在 /etc/php/7.0/fpm/mods-available 中看到 ini 文件

ls /etc/php/7.0/mods-available/ -al
total 28
drwxr-xr-x 2 root root 4096 Oct  5 23:04 .
drwxr-xr-x 4 root root 4096 Sep 24 13:09 ..
-rw-r--r-- 1 root root   64 Jun 14 15:50 gd.ini
-rw-r--r-- 1 root root   71 Jun 14 15:50 mysqli.ini
-rw-r--r-- 1 root root   72 Jun 14 15:50 mysqlnd.ini
-rw-r--r-- 1 root root   74 Jun 14 15:50 pdo_mysql.ini
-rw-r--r-- 1 root root   66 Jun 14 15:50 zip.ini

Nothing for xml or xmlwriter in there althrough I followed the exact same commands.在那里没有任何 xml 或 xmlwriter 我遵循完全相同的命令。

I can find xml.so in the same place than gd.so or zip.so but there is no way to enable this extension for now!我可以在与 gd.so 或 zip.so 相同的位置找到 xml.so,但目前无法启用此扩展!

find / -name xml.so
/usr/lib/php/20151012/xml.so

find / -name gd.so
/usr/lib/php/20151012/gd.so

Regards,问候,

OK I finally got this one.好的,我终于得到了这个。

I just ran我刚跑

apt-get purge php7.0-xml && apt-get install php7.0-xml

Before restarting PHP to see XML modules (Reader, Writer and others) enabled.在重新启动 PHP 以查看启用的 XML 模块(Reader、Writer 和其他)之前。

I can't figure out what happened but at least I'm done with this.我无法弄清楚发生了什么,但至少我已经完成了。

Regards,问候,

on Ubuntu 18.04 as root在 Ubuntu 18.04 上作为 root

apt install php-xmlwriter

Or use sudo:或者使用 sudo:

sudo apt install php-xmlwriter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM