首页 > 解决方案 > 在 PHP 中出现错误“找不到类 'DOMDocument'”

问题描述

我收到一个错误:

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'DOMDocument' not found in /var/www/html/vendor/embed/embed/src/Request.php:246

我在网上发现我必须安装php-xml和php-dom。首先,我检查了我的 php 版本:

/var/www/html# php -v
PHP 7.1.33-17+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug  7 2020 14:46:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33-17+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

然后,我安装了 php-xml 和 php-dom:

sudo apt-get install php7.1-dom
sudo apt-get install php7.1-xml

并重新启动 nginx:

sudo service nginx restart

但它仍然显示第一个错误。我已经进入了三个小时,这让我发疯了。

标签: phpubuntu

解决方案


推荐阅读