PHP 7 simpleXML

I am testing PHP7 and am experiencing a strange problem after a recent update. SimpleXML should be enabled by default, and my phpinfo page shows that it is available:

enter image description here

However, functions are not available:

 <?php if (function_exists('simplexml_load_file')) { echo "simpleXML functions are available.<br />\n"; } else { echo "simpleXML functions are not available.<br />\n"; } // result-- NOT available 

And the module is not listed as loaded:

 ~ $ php -m [PHP Modules] calendar Core ctype curl ... Reflection session shmop sockets SPL standard sysvmsg sysvsem sysvshm tokenizer Zend OPcache zlib 

Does anyone know if a workaround is for this?

Version Information:

 ~ $ php -v PHP 7.0.3-8+deb.sury.org~trusty+2 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies 
+46
php php-7 simplexml
Feb 24 '16 at 4:51
source share
7 answers

I had the same issue and am using Ubuntu 15.10.

In my case, in order to solve this problem, I installed the php7.0-xml package using the Synaptic Package Manager, which includes SimpleXml. So, after rebooting my Apache server, my problem was resolved. This package comes in a version of Debian, and you can find it here: https://packages.debian.org/sid/php7.0-xml .

+72
Feb 24 '16 at 13:56 on
source share
β€” -

For all those using Ubuntu with ppa:ondrej/php PPA, this will fix the problem:

apt install php7.0-mbstring php7.0-zip php7.0-xml

(see https://launchpad.net/~ondrej/+archive/ubuntu/php )

Thanks @Alexandre Barbosa for pointing this out!

EDIT 20160423:

One-liner to fix this problem:

 sudo add-apt-repository -y ppa:ondrej/php && sudo apt update && sudo apt install -y php7.0-mbstring php7.0-zip php7.0-xml 

(this will add the ppa mentioned above, and will also definitely have the latest php. We have been using OnpΕ™ej PHP ppa for almost two years now and it works like a charm)

+38
Feb 24 '16 at 22:34
source share

For Ubuntu 14.04 with

PHP 7.0.13-1 + deb.sury.org ~ trusty + 1 (cli) (NTS)

 sudo apt-get install php-xml 

worked for me.

+9
Nov 29 '16 at 5:11
source share

I use Bash on Windows (Ubuntu 16.04), and I just installed with php7.0-xml, and now everything works for PHP Symfony 3.2.7 requirements.

 sudo apt-get install php7.0-xml 
+8
Apr 19 '17 at 19:43 on
source share

For Alpine (in docker) you can use apk add php7-simplexml .

+5
Aug 08 '17 at 19:02
source share

------------------ on centos -------------------------

find out which package php-xml provides:

  yum provides php-xml 

, then from the output list select the appropriate one, set

 yum install php70u-xml-7.0.14-2.ius.centos7.x86_64 
+4
Jan 09 '17 at 8:09
source share

Usually on Debian systems you have a different PHP configuration for the CLI, and for PHP like Apache. Your phpinfo page can very well show that simplexml is enabled using the web server, while it is not enabled via the CLI.

+1
Feb 24 '16 at 5:12
source share



All Articles