Apologies but something weird has happened to me today with Symfony.
I am developing a webapp with a friend and decided to run a composer update this morning.
Everything was working correctly before, but once composer update finished I got a cache:clear error. It was about how Doctrine\Common\Persistence\ManagerRegistry;
was not found on several repositories, so I tried to autocomplete with PhpStorm who could resolve to Doctrine\Persistence\ManagerRegistry
all good.
Problem is once I corrected that on all repositories I got the following error when trying to run php bin/console
:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#4524
#message: """
Attempted to load class "MappingDriverChain" from namespace "Doctrine\Common\Persistence\Mapping\Driver".\n
Did you forget a "use" statement for "Doctrine\Persistence\Mapping\Driver\MappingDriverChain"?
"""
#code: 0
#file: "./var/cache/dev/ContainerO7VJLRg/App_KernelDevDebugContainer.php"
#line: 1223
trace: {
./var/cache/dev/ContainerO7VJLRg/App_KernelDevDebugContainer.php:1223 {
ContainerO7VJLRg\App_KernelDevDebugContainer->getDoctrine_Orm_DefaultEntityManagerService($lazyLoad = true)^
›
› $b = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
›
}
./var/cache/dev/ContainerO7VJLRg/App_KernelDevDebugContainer.php:6427 { …}
./var/cache/dev/ContainerO7VJLRg/App_KernelDevDebugContainer.php:6472 { …}
./var/cache/dev/ContainerO7VJLRg/App_KernelDevDebugContainer.php:899 { …}
./vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:90 { …}
./vendor/symfony/http-kernel/Kernel.php:572 { …}
./vendor/symfony/http-kernel/Kernel.php:131 { …}
./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
./vendor/symfony/console/Application.php:140 { …}
./bin/console:42 { …}
}
}
I shared it with my colleague who did not have the same issue. He ran composer update, and no issues at all on his side. So I just decided to push my changes to a different repository, and clone the project and try again. Same errors as before.
After that I decided to create a new symfony website from scratch and move the files over (after pulling his changes as well), (configs/src/templates/public etc) it worked like a charm, bin/console
works perfectly, symfony server:start
serves the page totally fine as well so we decided, cool let's move this into our shared repository, and he will try to clone it and run composer install.
As soon as he does, he gets exactly the same errors as me.
I tried cloning the project to another folder and exactly the same happened.
By the way, in spite of cache clear not working we are eliminating the cache folder at every single step.
I thought it would have something to do with symfony/orm-pack
being updated to version 2.0.0 but we downgraded it and it didn't fix anything.
Symfony version (for both of us) is 5.1 additional libraries we are using are: data-dog/audit-bundle
and ramsey/uuid-doctrine
not sure if that helps.
doctrine/persistence
- is that installed? Also, can you show the code triggering that error? As far as I see, the error message suggests a replacement, so maybe you are using the wrong namespace to load it? – Shannonshanny