Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DonSchoeman's avatar

How do I install the dom extension for PHP7?

I am trying to do a composer install for a laravel project on a staging server of ours but the composer dependency check fails at phpunit stating that it requires the ext-dom extension. I can find no information on how to install or enable the dom extension for PHP7. I compared the list of extensions installed on the server vs a Homestead box but I can't find anything obvious. Can anyone tell me which extension to install in order to resolve the missing dependency?

0 likes
16 replies
fideloper's avatar
Level 11

Some quick googling shows it might be the php-xml package, but I can only find results about CentOS. What kind of server are you running?

11 likes
willvincent's avatar

Homestead is ubuntu based, yeah? If so, ... sudo aptitude should bring up a full screen package manager, there may be a package you can install. Not sure about php7, but php5 the extension was enabled by default.

DonSchoeman's avatar

Thanks guys, it turns out that it was indeed the php-xml package, so the following solved the problem:

sudo apt-get install php-xml

I am using Ubuntu 14.04 in case anyone else also runs into this problem.

53 likes
jimmerioles's avatar

i had the same problem, but i installed php7.0-xml instead of php-xml and it solves the issue installing with phpunit

isn't php7.0-xml for php7?

in not so sure which is which and whose for who, hope somebody would enlighten me on this :/

5 likes
Multibyte's avatar

"sudo apt-get install php-xml" worked for my PHP 7 on Ubuntu 16.04 LTS.

11 likes
arifulhb's avatar

In Ubuntu 16.04 sudo apt-get install php-xml will install for PHP 7. I wanted to use in php5.6. So I needed to write sudo apt-get install php5.6-xml.

renandanton's avatar

Hello Guys,

I solved this issue with commands bellow:

$ sudo apt-get install php7.0-intl

$ sudo /etc/init.d/php7.0-fpm restart

These commands works for me in homestead with php7.0

1 like
codecrunch's avatar

Installing php7.0-xml & php7.0-mbstring worked for me.

2 likes
elias-alea's avatar

Actually, the problem is related to the extension sudo "php-xml", so sudo apt-get install php-xml should work and indeed it worked for me.

installing php7.0-mbstring is for when you have,

"laravel/framework v5.4.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system."

ShirleyConcep's avatar

In Debian 8 and php 7.1 I solved this issue with ...

$ sudo apt-get install php7.1-mbstring

$ sudo apt-get install php7.1-xml

$ sudo apt-get install php7.1-zip

3 likes
kevinfelisilda's avatar

I was able to get it working by installing the ff:

sudo apt-get install php7.0-xmlrpc php7.0-xml

ubuntu 16

2 likes
3eyedcoder's avatar

thanks for this tip. in my case i had to use php7.2-xml and that saved me a whole lot of headache

Please or to participate in this conversation.