简体   繁体   中英

Cannot enable XMLWriter module with PHP7 on Debian9

I am trying to install a PHP app that is using PHPSpreadSheet library.

Web server is Nginx; OS is Debian 9.5 and current PHP-FPM version is 7.0.

While trying to use PHPSpreadsheet library, I'm facing an error as below

Error: Class 'XMLWriter' not found

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

Line: 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.

<?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...

See below output from 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. This module is definitly not enabled!

Is there any other step I need to run to really enable this module in PHP environment?

Edit: I also had to install php7.0-gd and 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()

Everything seems normal for those modules as I can see ini files in /etc/php/7.0/fpm/mods-available

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.

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!

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.

I can't figure out what happened but at least I'm done with this.

Regards,

on Ubuntu 18.04 as root

apt install php-xmlwriter

Or use sudo:

sudo apt install php-xmlwriter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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