Search code examples
symfonycomposer-phpproduction-environmentsymfony5

Missing vendor asset in prod env of symfony error-handler


After upgrading to symfony 5, I found a warning of a missing asset of symfony's error-handler:

php.WARNING: Warning: include(/var/www/projekt/nakade/vendor/symfony/error-handler/ErrorRenderer/../Resources/assets/css/error.css): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0):

After investigating this issue I found the assets directory missing in prod environment while in dev env directory and css class is existing. I assume the css is missing because the component is just in require-dev.

"require-dev": { ... "symfony/browser-kit": "5.0.*", "symfony/css-selector": "5.0.*", "symfony/debug-bundle": "5.0.*", "symfony/maker-bundle": "^1.13", "symfony/phpunit-bridge": "^5.0", "symfony/profiler-pack": "1.0.*", "symfony/test-pack": "^1.0", "symfony/var-dumper": "5.0.*" },

The env var is set in .env.local APP_ENV=prod The error message showed up by the google-bot due to a missing robots.txt and sitemap.xml. THis is fixed and error and the warning is gone but I curious about it.

Has someone an idea how to fix this?


Solution

  • Found the answer by looking deeper at the stacktrace:

    [2020-04-16 23:33:35] php.CRITICAL: Uncaught Exception: The controller for URI "/robots.txt" is not callable. Controller "App\Controller\MyExceptionController" does neither exist as service nor as class.. {"exception":"[object] (InvalidArgumentException(code: ...

    This is a hint to a deprecation in twig.yaml:

    before:

    twig: exception_controller: 'App\Controller\MyExceptionController' ...

    after:

    twig: exception_controller: null ...