27

I have php 7.0 running on my ubuntu server.

php -m command says:

[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

But still when I run my website, its log says "PHP Fatal error: Call to undefined function simplexml_load_file()"

2
  • The PHP configuration used on the command-line is not necessarily the same one used when running the website. Try phpinfo() on a web page, or check your hosting configuration, to figure out what modules are loaded in that environment. Commented Mar 26, 2018 at 14:31
  • Simplexml is not loaded when checked using phpinfo(). But I tried enabling simplexml by command php a2enmod simplexml, still it does not gets enabled. The command does not gives error. Some site says restart /opt/php 7.0-fpm.. But the file is missing. Commented Mar 27, 2018 at 4:38

3 Answers 3

55

I had the same issue. I fixed it by installing php7.2-xml:

$ sudo apt-get install php7.2-xml
$ sudo systemctl reload apache2 

After that, SimpleXML got listed by php -m:

$ php -m | grep -i simple
SimpleXML
Sign up to request clarification or add additional context in comments.

3 Comments

Likewise, in CentOS 8, I solved it with "yum install php-xml"
"sudo apt-get install php7.4-xml" then "sudo systemctl reload apache2" on Ubuntu 20.04
In Ubuntu 22.04 I installed php-xml using sudo apt-get install php-xml and it worked!
3

I'm using ubuntu 18.04. When I checked for SimpleXML in module list, it was stated same like yours.

Then I check my phpinfo() which says it was pulling from different php version and not the same with php cli.

To check php cli version, I run php -v enter image description here

To check for phpinfo(), I put the function at the top of index.php of my script. enter image description here

After confirming that my phpcli version is different than whats in phpinfo,

I simply run this 2 command

sudo a2dismod php7.0

sudo a2enmod php7.3

Then restart my apache

sudo systemctl restart apache2

After that, I test again my phpinfo()

Now it is working.

enter image description here

Comments

0

For me, on Alpine, following line did the job:

apk add php7-simplexml

php7-xml appeared to be a different library.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.