Symfony4 Error loading classes custom folder "Expected to find class... but it was not found" Symfony4 Error loading classes custom folder "Expected to find class... but it was not found" symfony symfony

Symfony4 Error loading classes custom folder "Expected to find class... but it was not found"


Update your composer.json autoload setup

{    [...]    "autoload": {        "psr-4": {            "TestNamespace\\": "TestNamespace/",            "": "src/"        }    },    [...]}

After run: composer dump-autoload and try again.


composer dump-autoload --classmap-authoritative will only work if your src directory is present at the time you run the command.

This can be an issue with multi-stage Docker builds in particular, when you are normally only copying the composer.json/composer.lock into the build image.