Class 'DOMDocument' not found
Solution 1
You need to install the DOM extension. You can do so on Debian / Ubuntu using:
sudo apt-get install php-dom
And on Centos / Fedora / Red Hat:
yum install php-xml
If you get conflicts between PHP packages, you could try to see if the specific PHP version package exists instead: e.g. php53-xml
if your system runs PHP5.3.
Solution 2
PHP 7.0:
- Ubuntu:
apt-get install php7.0-xml
- CentOS / Fedora / Red Hat:
yum install php70w-xml
PHP 7.1:
- Ubuntu:
apt-get install php7.1-xml
- CentOS / Fedora / Red Hat:
yum install php71w-xml
PHP 7.2:
- Ubuntu:
apt-get install php7.2-xml
- CentOS / Fedora / Red Hat:
yum install php72w-xml
PHP 7.3:
- Ubuntu:
apt-get install php7.3-xml
- CentOS / Fedora / Red Hat:
yum install php73w-xml
PHP 7.4:
- Ubuntu:
apt-get install php7.4-xml
- CentOS / Fedora / Red Hat:
yum install php74w-xml
PHP 8.0
- Ubuntu:
apt-get install php8.0-xml
- CentOS 8 [with
php:remi-8.0
enabled]:dnf install php-xml
Solution 3
PHP8: (latest version)
sudo apt-get install php8.0-xml
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.
Solution 4
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
sudo apt-get install php5.6-xml
For PHP ver PHP7, Ubuntu:
sudo apt-get install php7.1-xml
or by
yum install php-xml
Solution 5
I'm using Centos and the followings worked for me , I run this command
yum --enablerepo remi install php-xml
And restarted the Apache with this command
sudo service httpd restart
Related videos on Youtube
ws_123
Updated on January 26, 2022Comments
-
ws_123 over 2 years
I've found an error on a page in my Magento application; it always show this message error when I visit it:
Fatal error: Class 'DOMDocument' not found in /home/.../lib/Zend/Feed/Abstract.php on line 95
Can you give me a solution? I'm using magento 1.4.1.1.
-
koopajah over 11 yearsThis answer (enable php-xml) seems coherent, why doubt it instead of just testing it? From a few google searches it seems to be one of the possible issues
-
ws_123 over 11 yearsi just scare when i try "yum install php-xml", it will disturb my magento site..
-
jirarium over 5 years
DomDocument
instead ofDOMDocument
can sometimes fix this issue .
-
-
ws_123 over 11 yearsi found --disable-dom in Configure Command, what should i do next?
-
JNDPNT over 11 yearsFor Cent OS: smartwebdeveloper.com/centos/…
-
Gromski over 11 yearsThat depends on your system. Worst case you have to recompile PHP from scratch.
-
zzapper over 10 yearsinstalling php-xml solved this for me but don't forget the 'service httpd restart'
-
David over 10 yearsI was running php 5.5 with the webtatic repo (Cent OS) and had to do
yum install php55w-xml
and that worked fine for me. Of course have to restart afterwards. -
Remi Collet over 8 yearsRelying on configure option is most often a mistake, read blog.remirepo.net/post/2010/09/29/phpinfo-BUG-or-PEBKAC so it have been removed from phpinfo output in some distrobution (debian, fedora...)
-
Anees Sadeek almost 8 years@ws_123 specify your php version while installing like
php70w-xml
-
dungphanxuan over 7 yearsi have same problem and run yum install php-xml so have error No Match for argument: php-xml
-
Shautieh over 7 years@zzapper thanks, that got me on the rails! In my case I needed to restart apache2
service apache2 restart
. -
Jahmic over 7 yearsremember to restart apache afterwards
-
Jahmic over 7 yearsremember to restart apache afterwards
-
user3413723 over 7 yearsThanks, restarting the server worked! I had to do
service apache2 restart
on ubuntu. -
StephanieQ about 7 yearsI'm running PHP 7 (7.0.15-1~dotdeb+8.1) on an Nginx VS (via Docker) and this worked like a charm! Don't forget to do `docker-compose restart'!
-
Cyclonecode about 7 yearsWorked for me running
php5.6
on ubuntu 14.04 and using thedompdf
package. -
Martin Zeitler about 7 yearson CentOS, module
php-xml
can be (at least for v5.6) installed withyum install php56w-common
; see webtatic.com/packages/php56 another (possible) pitfall may be, that only the file/etc/php.d/xml.ini
but not/etc/php-cli.d/xml.ini
is present. -
Jared Dunham about 7 yearsFor PHP7, it's just
php-doc
. -
Rafael Barros almost 7 yearsFor me:
sudo apt-get install php7.1-xml
-
DidThis over 6 yearsIf compiled from source, you could use
--enable-dom
-
Piyin over 6 yearsFor Ubuntu,
apt install php-xml
does the trick. And, of course, restarting apache afterwardssystemctl restart apache2
-
Silvan almost 6 yearsPHP 7.2, CentOS
yum install php72w-xml
and then restart service -
binki over 5 yearsIs there not a
php-xml
alias/virtual package? -
Amos Jeffries about 4 yearsThis is also starting to occur with php7.3 to 7.4 transition. When the web server PHP module is based on 7.3 and php-xml is 7.4. Updating to a consistent PHP version (either one) works fine.
-
Remi Collet over 3 yearsBetter to keep "remi-php7x" always enabled, as explained by the wizard, rpms.remirepo.net/wizard
-
The Coding Bus almost 3 yearsi'm not able to run this command in my namecheap hosting terminal. how can i resolve that error? Thank You
-
johnsnails over 2 yearsIn addition to restarting Apache, remember if you are using php's built in web server to kill and re serve your application.