1

I've just updated a project from Symfony 4.3 to 4.4. After the update when I have an error the page shown is the production error page with the "Oops! An Error Occurred!", not the dev error page with all the trace of the error.

Also the profiler doesn't log the error page, I can see all the requests in the profiler but no the ones with errors.

If I look at the logs (I am using docker) I can see the php errors there:

$ docker logs php
172.21.0.3 -  17/Jun/2020:09:50:53 +0000 "GET /index.php" 500
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "NOTICE: PHP message: PHP Fatal error:  Uncaught Twig\Error\SyntaxError: Unexpected "}". in /app/templates/professionals/artists/list.html.twig:26"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "Stack trace:"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#0 /app/vendor/twig/twig/src/Lexer.php(292): Twig\Lexer->lexExpression()"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#1 /app/vendor/twig/twig/src/Lexer.php(186): Twig\Lexer->lexVar()"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#2 /app/vendor/twig/twig/src/Environment.php(542): Twig\Lexer->tokenize(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#3 /app/vendor/twig/twig/src/Environment.php(595): Twig\Environment->tokenize(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#4 /app/vendor/twig/twig/src/Environment.php(408): Twig\Environment->compileSource(Object(Twig\Source))"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#5 /app/vendor/twig/twig/src/Environment.php(381): Twig\Environment->loadClass('__TwigTemplate_...', 'professionals/a...', NULL)"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#6 /app/vendor/twig/twig/src/Environment.php(359): Twig\Environment->loadTemplate('professionals/a...')"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#7 /app/vendor/symfony/twig-bridge/TwigEngine.php(135): Twig\Environment->load('professionals/a...')"
[17-Jun-2020 09:50:53] WARNING: [pool www] child 6 said into stderr: "#8 /app/vendor/symfony/twig-bridge/TwigEngine.php(54): Symfony\Bridge\Twig\TwigEngine->load(..."

The .env file is set to APP_ENV=dev

yivi
  • 42,438
  • 18
  • 116
  • 138
David Rojo
  • 2,337
  • 1
  • 22
  • 44

3 Answers3

3

In Symfony 4.4 the ErrorHandler component was released, that replaced the Debug component.

With this, the location of some files has changed.

You need to locate config/routes/dev/twig.yaml, and remove these lines:

# config/routes/dev/twig.yaml
_errors:
    resource: '@TwigBundle/Resources/config/routing/errors.xml'
    prefix:   /_error

In its place, create a new file config/routes/dev/framework.yaml with this content:

# config/routes/dev/framework.yaml
_errors:
    resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
    prefix:   /_error

This should reinstate the old error-preview pages during development.

yivi
  • 42,438
  • 18
  • 116
  • 138
  • Hi, thanks for the comment, but after making the change the debug error page still doesn't show, I've also cleared the cache and removed all vendors folder and installed again but still the production error page is shown. – David Rojo Jun 18 '20 at 07:49
-1

Found the error. It was a misconfiguration with the package FosRestBundle.

I had friendsofsymfony/rest-bundle at version 2.5. I upgraded to 2.8 and in the fos_rest-yml removed the configuration "exception_controller: 'fos_rest.exception.controller:showAction".

After that everything worked fine again.

David Rojo
  • 2,337
  • 1
  • 22
  • 44
-1

The Debug class has changed from Symfony\Component\Debug\Debug to Symfony\Component\ErrorHandler\Debug in Symfony 4.4

So you have to change your app_dev.php and other debug front controllers, so that Debug::enable() leads to the new one.

https://github.com/symfony/symfony/issues/36254#issuecomment-701260396

theredled
  • 998
  • 9
  • 20