在 puphpet PHP 5.6 上找不到“SimpleXMLElement”类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35223926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:23:23  来源:igfitidea点击:

Class 'SimpleXMLElement' not found on puphpet PHP 5.6

phpapachepuphpet

提问by Marco Aurélio Deleu

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

这是一个在生产中运行良好的项目,曾经在我以前使用 WampServer 和 PHP 5.6.2 的计算机上工作。现在我有了一台新电脑,我对用 puphpet 设置一个虚拟环境很感兴趣,但是我收到了这个错误。

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

根据 Docs,默认情况下,SimpleXMLElement 类应该随 PHP 一起提供。我没有php.ini在我的 phpinfo()上找到任何重要信息,有以下内容:

SimpleXML   Sterling Hughes, Marcus Boerger, Rob Richards

Any tips?

有小费吗?

Thanks

谢谢

Update

更新

Just to add this

只是为了添加这个

enter image description here

在此处输入图片说明

回答by Marco Aurélio Deleu

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

问题是我使用的是 Cent OS,而在这个 Linux 发行版中,这个php-libxml包不是默认的。

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

我最终通过 PuPHPet GUI 生成了一台新机器,并将以下要安装的软件包添加到系统包中:

php-xml, php-simplexml

Problem solved.

问题解决了。



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

对于使用 PHP 7 和 Ubuntu 的用户,@MPS 通过运行apt-get install php7.0-xmlservice apache2 restart.

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

在 Centos 上,我们需要安装 XML php 包。您可以尝试yum install php56w-xml或者yum install php70w-xml如果您正在使用 PHP 7.0 的 php70w 存储库

回答by Prabhu Nandan Kumar

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

我遇到了这个问题,并最终通过运行以下命令解决了这个问题:

apt install php5.6-xml

After it reload and restart apache2 service :

重新加载并重新启动 apache2 服务后:

service apache2 reload   

service apache2 restart

And a PHP restart may be required

并且可能需要重启 PHP

systemctl restart php-fpm

回答by Bruce Tong

If you are running ubuntu in AWS Cloud 9. Then from your menu bar->Window->New Terminal->type sudo apt install php-xml

如果您在 AWS Cloud 9 中运行 ubuntu。然后从您的菜单栏->窗口->新终端->输入 sudo apt install php-xml