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

TheDude's avatar

Class "DOMDocument" not found

I've read the other posts on laracasts about Class "DOMDocument" not found, but none seem to answer the question.

The error occurs on php artisan storage:link php artisan clear-compiled but 'php artisan' runs fine.

Class "DOMDocument" not found
  at vendor/nunomaduro/termwind/src/HtmlRenderer.php:32
     28▕      * Parses the given html.
     29▕      */
     30▕     public function parse(string $html): Components\Element
     31▕     {
  ➜  32▕         $dom = new DOMDocument();
     33▕ 
     34▕         if (strip_tags($html) === $html) {
     35▕             return Termwind::span($html);
     36▕         }
  21  artisan:37
  Illuminate\Foundation\Console\Kernel::handle()

Running PHP inside docker, php-dom seems to be installed by default. php -m reveals 'dom' is installed. This error started after a few pushes and pull of git to the server.

dd(class_exists('DOMDocument')) returns true

php -m results

[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
imagick
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
Xdebug
0 likes
4 replies
AddWebContribution's avatar

@the-dude in docker when we change anything we need to restart the whole server have you tried that

   sudo apt-get udpate
    sudo systemctl restart apache2
1 like
TheDude's avatar

Thanks for your reply.

I just restarted my PC just now and it fixed the problem. Pretty stupid huh?

nian's avatar

That issue happened when I updated php version.

I checked php installed extension couldn't find DOM.

so I tired: sudo apt install phpX.X-xml, and solved issue.

1 like
Disciple's avatar

apt install php-xml worked for me

1 like

Please or to participate in this conversation.