【问题标题】:500 Error after symfony update from 4.4.10 to 5.1symfony 从 4.4.10 更新到 5.1 后出现 500 错误
【发布时间】:2020-08-23 12:55:03
【问题描述】:

我将 symfony 从 4.4.10 更新到 5.1。

因此,我多次调用“作曲家更新”进行更改,例如 ..

  1. 将 TranslatorInterface 更新为 Symfony\Contracts\Translation\TranslatorInterface;
  2. 在 twig.yaml 中更新 errors.xml 资源路径:'@FrameworkBundle/Resources/config/routing/errors.xml'
  3. 注释配置设置模板 -> 引擎:['twig', 'php']

之后“composer update”调用现在可以成功运行,没有任何错误。

但是现在我在浏览器中加载页面时收到 500 错误。而且我在 Ubuntu 18.04 中既没有在 var/log/dev.log 中也没有在 /var/log/apache2/error.log 中得到 any 错误描述。直到现在我才知道为什么它不起作用。

你能帮帮我吗?提前致谢。

【问题讨论】:

  • .env.local 中设置APP_ENV=devAPP_DEBUG=1 并重试
  • 我在 .env.local 中进行了此更改(清除缓存)。但我仍然在 var/log/dev.log 和 /var/log/apache2/error.log 中都没有看到错误消息。
  • 运行你的 PHPUnit 测试时是否出现了一些东西?
  • 使用 Symfony 控制台会得到什么?
  • symfony 日志和 apache 日志不是您的 PHP 日志。检查一下。

标签: php symfony


【解决方案1】:

现在我知道问题所在了。从 4.4.20 更新到 5.1 后,您还必须更新 public/index.php 因为例如使用 Symfony\Component\Debug\Debug 中的路径已更改。

这就是我现在在 public/index.php 中使用此代码的原因:

<?php

use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
    umask(0000);

    Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

取自: https://raw.githubusercontent.com/symfony/recipes/master/symfony/framework-bundle/4.4/public/index.php

感谢大家的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    • 2012-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多