Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class 'SimpleXMLElement' not found on puphpet PHP 5.6

I've been stuck at this error for hours now and I can't seem to find anything useful on the internet about it. The error is the classic

Fatal error: Class 'SimpleXMLElement' not found in 
/var/www/NavPHP/nav/plugin/log/NavLog.php on line 29

I'm not using Namespace so that's not the problem.

It's a project that works fine in production and used to work in my former computer with WampServer and PHP 5.6.2. Now that I got a new computer, I'm interested in setting up a virtual environment with puphpet, but I'm getting this error.

According to Docs, the SimpleXMLElement class should come with PHP by default. I didn't find any important information on php.ini and in my phpinfo() there's the following:

SimpleXML   Sterling Hughes, Marcus Boerger, Rob Richards

Any tips?

Thanks

Update

Just to add this

enter image description here

like image 394
Marco Aurélio Deleu Avatar asked Feb 05 '16 12:02

Marco Aurélio Deleu


2 Answers

The problem was that I was using Cent OS and in this Linux Distribution, the php-libxml package does not come as default.

I ended up generating a new machine through PuPHPet GUI and added to the System Package the following packages to be installed:

php-xml, php-simplexml

Problem solved.


For those using PHP 7 and Ubuntu, @MPS solved it by running apt-get install php7.0-xml and service apache2 restart.

On Centos, we need to install the XML php package. You can try yum install php56w-xml or yum install php70w-xml if you're using php70w repository for PHP 7.0

like image 155
Marco Aurélio Deleu Avatar answered Nov 14 '22 02:11

Marco Aurélio Deleu


I faced this issued and finally solved by run following command :

apt install php5.6-xml

After it reload and restart apache2 service :

service apache2 reload   

service apache2 restart

And a PHP restart may be required

systemctl restart php-fpm
like image 34
Prabhu Nandan Kumar Avatar answered Nov 14 '22 00:11

Prabhu Nandan Kumar