-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed as duplicate of#62589
Closed as duplicate of#62589
Copy link
Description
Symfony version(s) affected
7.4.0
Description
After upgrading from Symfony 7.3.7 to 7.4.0, it seems that DI is failing whe trying to register classes when the parent class is missing.
The previous behaviour was quite useful e.g. when writing factory classes for Foundry.
AFAICT it was initially possible since this PR: #25932
How to reproduce
- Create a Symfony 7.3 project, add Doctrine ORM & Foundry
- Create an entity & a factory
- Run
APP_ENV=prod composer install --no-dev, it works - Run
composer install - Upgrade to Symfony 7.4
- Run
APP_ENV=prod composer install --no-dev, it now fails with the following error:
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!
!! // Clearing the cache for the prod environment with debug false
!!
!! {"message":"Uncaught Error: Class \"Zenstruck\\Foundry\\Persistence\\PersistentObjectFactory\" not found","context":{"exception":{"class":"Error","message":"Class \"Zenstruck\\Foundry\\Persistence\\PersistentObjectFactory\" not found","code":0,"file":"/home/jmsche/Sites/reproducers/di-autoconfigure-symfony/src/Factory/ArticleFactory.php:11"}},"level":500,"level_name":"CRITICAL","channel":"php","datetime":"2025-11-28T11:19:53.659492+01:00","extra":{}}
!! 11:19:53 CRITICAL [php] Uncaught Error: Class "Zenstruck\Foundry\Persistence\PersistentObjectFactory" not found ["exception" => Error { …}]
!!
!! In ArticleFactory.php line 11:
!!
!! Attempted to load class "PersistentObjectFactory" from namespace "Zenstruck
!! \Foundry\Persistence".
!! Did you forget a "use" statement for another namespace?
!!
!!
!! cache:clear [--no-warmup] [--no-optional-warmers]
!!
!!
Script @auto-scripts was called via post-install-cmd
Possible Solution
No response
Additional Context
I created a reproducer here: https://github.com/jmsche/symfony-di-reproducer
You can see the difference between 7.3 & 7.4 branches when running APP_ENV=prod composer install --no-dev (the only difference between both branches is the Symfony 7.4 upgrade).
alexislefebvre