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

Lar*_*una 3 php apache symfony doctrine-orm

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

\n\n

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

\n\n

我已将我的 Symfony 文件上传到 /var/www/html/project 并成功设置了我的parameter.yml 文件,设置了数据库,并完成了所有安装要求。我已经完成了composer.phar安装,学说:架构:更新等 - 这一切都有效。

\n\n

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

\n\n
<VirtualHost *:80>\n    ServerName site.com\n    ServerAlias dev.site.com\n\n        ServerAdmin admin@site.com\n        DocumentRoot /var/www/html/project/web\n        DirectoryIndex app.php\n        <Directory /var/www/html/project/web >\n                DirectoryIndex app.php\n                AllowOverride All\n                Allow from All\n        </Directory>\n\n        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n        # error, crit, alert, emerg.\n        # It is also possible to configure the loglevel for particular\n        # modules, e.g.\n        #LogLevel info ssl:warn\n\n        ErrorLog ${APACHE_LOG_DIR}/error.log\n        CustomLog ${APACHE_LOG_DIR}/access.log combined\n\n        # For most configuration files from conf-available/, which are\n        # enabled or disabled at a global level, it is possible to\n        # include a line for only one particular virtual host. For example the\n        # following line enables the CGI configuration for this host only\n        # after it has been globally disabled with "a2disconf".\n        #Include conf-available/serve-cgi-bin.conf\n\n</VirtualHost>\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

现在,当我查看我的网站时,我得到

\n\n

此页面无法正常工作\xe2\x80\x99

\n\n

dev.site.com 目前无法处理此请求。HTTP 错误\n 500

\n
\n\n

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

\n\n

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

\n\n
\n

未捕获的类型错误:\n Doctrine\\Common\\Annotations\\AnnotationRegistry::registerLoader()\n 的返回值必须是 Doctrine\\Common\\Annotations\\void 的实例,没有\n 在\n /var 中返回/www/html/project/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117\\nStack\n 跟踪:\\n#0 /var/www/html/rekonnect/app/autoload .php(9):\n Doctrine\\Common\\Annotations\\AnnotationRegistry::registerLoader(Array)\\n#1\n /var/www/html/project/web/app.php(6):\ n require(\'/var/www/html/p...\')\\n#2 {main}\\n 抛出\n /var/www/html/project/vendor/doctrine/annotations/lib /Doctrine/Common/Annotations/AnnotationRegistry.php\n 第 117 行

\n
\n\n

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

\n\n

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

\n

Nic*_*ich 5

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

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

[..] 必须是 Doctrine\Common\Annotations\void 的实例