php 未找到“DOMDocument”类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14395239/
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-25 07:11:03  来源:igfitidea点击:

Class 'DOMDocument' not found

phpxmlmagento

提问by ws_123

I've found an error on a page in my Magento application; it always show this message error when I visit it:

我在 Magento 应用程序的页面上发现错误;当我访问它时,它总是显示此消息错误:

Fatal error: Class 'DOMDocument' not found in /home/.../lib/Zend/Feed/Abstract.php on line 95

致命错误:在第 95 行的 /home/.../lib/Zend/Feed/Abstract.php 中找不到“DOMDocument”类

Can you give me a solution? I'm using magento 1.4.1.1.

你能给我一个解决方案吗?我正在使用 magento 1.4.1.1。

回答by Dean

You need to install the DOMextension. You can do so on Debian / Ubuntu using:

您需要安装DOM扩展。您可以在 Debian / Ubuntu 上使用:

sudo apt-get install php-dom

And on Centos / Fedora / Red Hat:

在 Centos / Fedora / Red Hat 上:

yum install php-xml

If you get conflicts between PHP 5 and PHP 5.3 packages, you could try to see if the php53-xmlpackage exists instead.

如果 PHP 5 和 PHP 5.3 包之间发生冲突,您可以尝试查看该php53-xml包是否存在。

回答by Limon Monte

PHP 7.0:

PHP 7.0

  • Ubuntu: apt-get install php7.0-xml
  • CentOS / Fedora / Red Hat: yum install php70w-xml
  • Ubuntu: apt-get install php7.0-xml
  • CentOS / Fedora / 红帽: yum install php70w-xml

PHP 7.1:

PHP 7.1

  • Ubuntu: apt-get install php7.1-xml
  • CentOS / Fedora / Red Hat: yum install php71w-xml
  • Ubuntu: apt-get install php7.1-xml
  • CentOS / Fedora / 红帽: yum install php71w-xml

PHP 7.2:

PHP 7.2

  • Ubuntu: apt-get install php7.2-xml
  • CentOS / Fedora / Red Hat: yum install php72w-xml
  • Ubuntu: apt-get install php7.2-xml
  • CentOS / Fedora / 红帽: yum install php72w-xml

PHP 7.3:

PHP 7.3

  • Ubuntu: apt-get install php7.3-xml
  • CentOS / Fedora / Red Hat: yum install php73w-xml
  • Ubuntu: apt-get install php7.3-xml
  • CentOS / Fedora / 红帽: yum install php73w-xml

PHP 7.4:

PHP 7.4

  • Ubuntu: apt-get install php7.4-xml
  • CentOS / Fedora / Red Hat: yum install php74w-xml
  • Ubuntu: apt-get install php7.4-xml
  • CentOS / Fedora / 红帽: yum install php74w-xml

回答by Albert s

PHP7: the latest version:

PHP7:最新版本:

sudo apt-get install php7.1-xml

you can also do:

你也可以这样做:

sudo apt-get install php-dom

and apt-get will show you where it is

apt-get 会告诉你它在哪里

回答by ikuchris

I'm using Centosand the followings worked for me , I run this command

我正在使用Centos并且以下对我有用,我运行此命令

yum --enablerepo remi install php-xml

And restarted the Apache with this command

并使用此命令重新启动 Apache

sudo service httpd restart

回答by inrsaurabh

Package php-dom is a virtual package provided by:
  php7.1-xml 7.1.3+-3+deb.sury.org~xenial+1
  php7.0-xml 7.0.17-3+deb.sury.org~xenial+1
  php5.6-xml 5.6.30-9+deb.sury.org~xenial+1
You should explicitly select one to install.

In case anyone using 5.6 versions then go with this way

如果有人使用 5.6 版本,则采用这种方式

sudo apt-get install php5.6-xml

For Php Ver PHP7, Ubuntu:

对于 PHP Ver PHP7,Ubuntu:

sudo apt-get install php7.1-xml

or by

或由

yum install php-xml

回答by deceze

Create an empty PHP file and put only <?php phpinfo();in it, look at it in a browser.
Check if you can spot --disable-domin the configuration options and/or if you can see details about the DOM extension in the list below.

创建一个空的 PHP 文件并只<?php phpinfo();放入其中,在浏览器中查看。
检查您是否可以--disable-dom在配置选项中找到和/或您是否可以在下面的列表中看到有关 DOM 扩展的详细信息。

If you cannot see DOM in the list or you see it is disabled, your PHP installation does not include the DOM extension. You'll need to recompile your PHP installation from source to remedy that.

如果您在列表中看不到 DOM 或您看到它被禁用,则您的 PHP 安装不包括 DOM 扩展。您需要从源代码重新编译 PHP 安装以解决该问题。

回答by Augusto Duncan

This help for me (Ubuntu Linux) PHP 5.6.3

这对我的帮助 (Ubuntu Linux) PHP 5.6.3

sudo apt-get install php5.6-dom

须藤 apt-get 安装 php5.6-dom

Thats work for me.

那对我有用。

回答by B2F

On fedora 26:

在 Fedora 26 上:

dnf install php-dom

Fixes it !

修复它!

回答by Ari

For Centos 7 and php 7.1:
yum install php71w-xml
apachectl restart

对于 Centos 7 和 php 7.1:
yum install php71w-xml
apachectl restart

回答by DidThis

If compiling from source with --disable-allthen DOMDocument support can be enabled with
--enable-dom

如果从源代码编译,--disable-all则可以启用 DOMDocument 支持
--enable-dom

Example:

例子:

./configure --disable-all --enable-dom

Tested and working for Centos7 and PHP7

已测试并适用于 Centos7 和 PHP7