New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration dependency injection in Symfony 7.0 #521
Comments
No. As you said, the upstream interface is gone. We don't have a replacement (yet?).
Yes.
The docs change would currently be to remove the mention of it from the docs or at least add a note that the feature is gone when upgrading to Symfony 7. |
That being said, injecting the whole container is highly discouraged by Symfony. If we were to build a replacement, we should either:
|
Thanks for your reply. Good to know there's no replacement yet.
Yes, by 'replicate' I meant in a way that is idiomatic in the newest Symfony version, so your suggestions make sense. |
Please, give an working example of custom migration factories that should be used to inject additional dependencies into migrations. |
Nobody can give you a working example for a feature that doesn't exist. |
I'm somewhat perplexed by the changes since Symfony 7.0. Since the ContainerAwareInterface is no longer available, does this mean there's no way to inject or access services within migrations? As a newcomer to Symfony, my understanding is that the framework heavily relies on "services" and dependency injection. However, it seems there's no way to utilize these services within migrations since they aren't registered as services. This limitation might be a significant drawback for adopting Symfony 7.0 in my scenario. I've noticed that this issue hasn't generated much discussion or feedback, which surprises me given its potential impact. Could anyone clarify how we're supposed to handle this in Symfony 7? What are the suggested workarounds? |
That is correct.
You cannot.
There are none. This bundle does not support loading services into migrations until someone builds that feature. |
The current documentation (https://symfony.com/bundles/DoctrineMigrationsBundle/current/index.html#migration-dependencies) refers to using
ContainerAwareInterface
in order to inject the entire container into a migration. In Symfony 6.4 this interface is deprecated, and it is removed in 7.0. (symfony/symfony-docs#18440)Is there a recommended way to tackle dependency injection for migrations in Symfony 7.0? Are code changes needed in this library in order to replicate the old functionality, or is an update of the docs sufficient?
The text was updated successfully, but these errors were encountered: