我输入以下命令来同步数据库
php bin/console doctrine:database:create
但是它返回了以下错误消息:
PHP致命错误:未捕获的Symfony \ Component \ Debug \ Exception \ ClassNotFoundException:尝试加载类" DOMDocument"来自全局命名空间。 你忘记了"使用"声明?在/opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php:52 堆栈跟踪: 0 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(261):Symfony \ Component \ Config \ Util \ XmlUtils :: loadFile(' /opt/lampp/htdo...' ;, Array) 1 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(41):Symfony \ Component \ DependencyInjection \ Loader \ XmlFileLoader-> parseFileToDOM(&#39) ; /选择/ LAMPP / HTDO ...') 2 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php(58):Symfony \ Component \ DependencyInjection \ Loader \ XmlFileLoader-> load(&#39) ; web.xml中') 3 / opt / lampp / htdocs / linguavel / vendor / symfony / symfony / src / Symfony / Component / DependencyInjection / Comp in / opt / lampp / htdocs / linguavel / vendor / symfony / symfony / src / Symfony / Component / Config / Util第52行的/XmlUtils.php
有人知道如何解决这个问题吗? 谢谢#)
修改
当Benjamin告诉我这样做时,我运行了作曲家安装,它让我回答:
> Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" c
ommand:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\Class
NotFoundException: Attempted to load class "DOMDocument" from the
global namespace.
Did you forget a "use" statement? in /opt/lampp/htdocs/linguavel/v
endor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.p
hp:52
Stack trace:
#0 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/
Component/DependencyInjection/Loader/XmlFileLoader.php(261): Symfo
ny\Component\Config\Util\XmlUtils::loadFile('/opt/lampp/htdo...',
Array)
#1 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/
Component/DependencyInjection/Loader/XmlFileLoader.php(41): Symfon
y\Component\DependencyInjection\Loader\XmlFileLoader->parseFileToD
OM('/opt/lampp/htdo...')
#2 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/
Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php(
58): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->l
oad('web.xml')
#3 /opt/lampp/htdocs/linguavel/vendor/symfony/symfony/src/Symfony/
Component/DependencyInjection/Comp in /opt/lampp/htdocs/linguavel/
vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.
php on line 52
.
新编辑:
当我输入作曲家更新时,它会返回给我:
要启用扩展程序,请验证它们是否已在这些.ini文件中启用:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/15-xml.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-dom.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-simplexml.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
- /etc/php/7.0/cli/conf.d/20-wddx.ini
- /etc/php/7.0/cli/conf.d/20-xmlreader.ini
- /etc/php/7.0/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.0/cli/conf.d/20-xsl.ini
您还可以在终端内运行php --ini
以查看PHP在CLI模式下使用的文件。
答案 0 :(得分:6)
我终于设法解决了这个问题:
$ sudo apt-get install php-curl
$ sudo apt-get install php-mbstring
$ sudo apt-get update
$ composer install
根据我的理解,出现这个问题是因为我有php7.0
如果您使用的是php7.0和symfony 2,请运行以下命令
$sudo apt-get install php7.0-curl php7.0-mbstring php7.0-zip php7.0-xml
在那之后
php app/check.php
查看是否还有其他缺失要求。
答案 1 :(得分:4)
顺便问一下,你试过跑步吗?
(?:...)
看看那些展示给你的东西? 您可能缺少安装要求......
答案 2 :(得分:0)
您的计算机上没有安装PHP ext/dom
扩展程序。在Ubuntu上,您需要运行类似sudo apt-get install php-xml
的内容。
修改强>
似乎正确安装了ext/dom
。请使用
<?php
namespace Test;
$d = new \DOMDocument();
如果可以,您的设置中会出现严重问题。
答案 3 :(得分:0)
我遇到了同样的问题。
运行 php bin / symfony_requirements ,例如 @Alvin Bunk ,并检查可用的错误。我的问题出在 php.ini 。我的服务器上有两个php模块 5.6 和 7.0 。我当前的模块是 5.6 ,但symfony从 7.0 读取 php.ini 。所以我删除了最后一个版本然后我只用 date.timezone 得到了一个错误,因为它被注释掉了。
现在它有效......