gpt4 book ai didi

php - Symfony 3 - Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() 必须是 Doctrine\Common\Annotations\void 的实例,没有返回

转载 作者:行者123 更新时间:2023-12-01 21:13:20 25 4
gpt4 key购买 nike

我有一个使用 Ubuntu 16 设置的 EC2 服务器,并安装了 LAMP 和 Symfony3。

服务器在线,所以没有问题。

我已将我的 Symfony 文件上传到/var/www/html/project 并成功设置了我的parameter.yml 文件,设置了数据库,并完成了所有安装要求。我已经完成了composer.phar安装、doctrine:schema:update等——一切正常。

我已将 000-default.conf 更改为以下内容并重新启动了 apache。

<VirtualHost *:80>
ServerName site.com
ServerAlias dev.site.com

ServerAdmin admin@site.com
DocumentRoot /var/www/html/project/web
DirectoryIndex app.php
<Directory /var/www/html/project/web >
DirectoryIndex app.php
AllowOverride All
Allow from All
</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

Now, when I go to view my site I get

This page isn’t working

dev.site.com is currently unable to handle this request. HTTP ERROR 500

因此,为了测试并查看 000-default.conf 配置是否设置为正确路由到我的 Symfony 安装,我编辑了 web/app.php 文件并添加了 echo 1;死;在标题处。然后我可以让“1”显示在页面上,这样我就知道服务器正在工作并且默认站点正在工作并将所有请求路由到正确的位置。

当我查看 error.log 时,我收到以下信息,我不确定该怎么做或如何解决此错误:

Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() must be an instance of Doctrine\Common\Annotations\void, none returned in /var/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117\nStack trace:\n#0 /var/www/html/rekonnect/app/autoload.php(9): Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(Array)\n#1 /var/www/html/project/web/app.php(6): require('/var/www/html/p...')\n#2 {main}\n thrown in /var/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 117

我查看了 var/logs/prod.log,但找不到任何内容说明为什么我的项目抛出 500 错误。

我不知道接下来要做什么才能让我的 Symfony 项目显示在浏览器中。有什么帮助吗?

最佳答案

您的服务器上可能安装了 PHP 版本 <7.1。更新您的 PHP 版本以解决该问题。

void 返回类型是在 PHP 7.1 中添加的。 (参见此answer)。 Doctrine 使用 void 返回类型,但 PHP 似乎在 Doctrine 命名空间中查找无法找到的类型。

[..] must be an instance of Doctrine\Common\Annotations\void

关于php - Symfony 3 - Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() 必须是 Doctrine\Common\Annotations\void 的实例,没有返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46668703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com