Class 'DOMDocument' not found

268,103

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
Share:
268,103

Related videos on Youtube

ws_123
Author by

ws_123

Updated on January 26, 2022

Comments

  • ws_123
    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
      koopajah over 11 years
      This 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
      ws_123 over 11 years
      i just scare when i try "yum install php-xml", it will disturb my magento site..
    • jirarium
      jirarium over 5 years
      DomDocument instead of DOMDocument can sometimes fix this issue .
  • ws_123
    ws_123 over 11 years
    i found --disable-dom in Configure Command, what should i do next?
  • JNDPNT
    JNDPNT over 11 years
  • Gromski
    Gromski over 11 years
    That depends on your system. Worst case you have to recompile PHP from scratch.
  • zzapper
    zzapper over 10 years
    installing php-xml solved this for me but don't forget the 'service httpd restart'
  • David
    David over 10 years
    I 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
    Remi Collet over 8 years
    Relying 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
    Anees Sadeek almost 8 years
    @ws_123 specify your php version while installing like php70w-xml
  • dungphanxuan
    dungphanxuan over 7 years
    i have same problem and run yum install php-xml so have error No Match for argument: php-xml
  • Shautieh
    Shautieh over 7 years
    @zzapper thanks, that got me on the rails! In my case I needed to restart apache2 service apache2 restart.
  • Jahmic
    Jahmic over 7 years
    remember to restart apache afterwards
  • Jahmic
    Jahmic over 7 years
    remember to restart apache afterwards
  • user3413723
    user3413723 over 7 years
    Thanks, restarting the server worked! I had to do service apache2 restart on ubuntu.
  • StephanieQ
    StephanieQ about 7 years
    I'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
    Cyclonecode about 7 years
    Worked for me running php5.6 on ubuntu 14.04 and using the dompdf package.
  • Martin Zeitler
    Martin Zeitler about 7 years
    on CentOS, module php-xml can be (at least for v5.6) installed with yum 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
    Jared Dunham about 7 years
    For PHP7, it's just php-doc.
  • Rafael Barros
    Rafael Barros almost 7 years
    For me: sudo apt-get install php7.1-xml
  • DidThis
    DidThis over 6 years
    If compiled from source, you could use --enable-dom
  • Piyin
    Piyin over 6 years
    For Ubuntu, apt install php-xml does the trick. And, of course, restarting apache afterwards systemctl restart apache2
  • Silvan
    Silvan almost 6 years
    PHP 7.2, CentOS yum install php72w-xml and then restart service
  • binki
    binki over 5 years
    Is there not a php-xml alias/virtual package?
  • Amos Jeffries
    Amos Jeffries about 4 years
    This 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
    Remi Collet over 3 years
    Better to keep "remi-php7x" always enabled, as explained by the wizard, rpms.remirepo.net/wizard
  • The Coding Bus
    The Coding Bus almost 3 years
    i'm not able to run this command in my namecheap hosting terminal. how can i resolve that error? Thank You
  • johnsnails
    johnsnails over 2 years
    In addition to restarting Apache, remember if you are using php's built in web server to kill and re serve your application.