Skip to content

Feat: Allow Dependency Injection from Symfony into Corto#1874

Merged
johanib merged 1 commit intoupgrade-84from
feature/twig_di
Nov 5, 2025
Merged

Feat: Allow Dependency Injection from Symfony into Corto#1874
johanib merged 1 commit intoupgrade-84from
feature/twig_di

Conversation

@johanib
Copy link
Contributor

@johanib johanib commented Oct 8, 2025

Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874

@johanib johanib linked an issue Oct 8, 2025 that may be closed by this pull request
@johanib johanib mentioned this pull request Oct 8, 2025
5 tasks
johanib added a commit that referenced this pull request Oct 8, 2025
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
@johanib johanib changed the title Properly allow service injection into corto Feat: Allow Dependency Injection from Symfony into Corto Oct 8, 2025
@johanib johanib moved this from New to In Progress in PHP development Oct 9, 2025
@johanib johanib requested a review from MKodde October 28, 2025 11:24
Copy link
Member

@MKodde MKodde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting PR! I see you deprecated the current way of working with the 'old' DiContainer. And you hint that any new service should be added to the new runtime version. Would it not be more elegant to move them all right now? That way, you can actually remove the old version in the next version. Now you might run into unforeseen issues and end up keeping the old and the new for a long time.

@github-project-automation github-project-automation bot moved this from In Progress to Backlog in PHP development Oct 29, 2025
Copy link
Member

@MKodde MKodde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRL @johanib convinced me to not big bang move all services to the new Runtime version. I then suggested to add some nuance to the instructions found in the PHPDoc

@johanib
Copy link
Contributor Author

johanib commented Oct 29, 2025

IRL @johanib convinced me to not big bang move all services to the new Runtime version. I then suggested to add some nuance to the instructions found in the PHPDoc

After discussion:

  • The thing is, the new situation is also not ideal. As it is not possible to directly inject dependencies into the classes that need them.
  • The old way cannot be removed 100%, because that would probably be a very big refactor, as the bootstrapping would be changed. But it would be possible to move 90% of the services to the new container.

I agree it would be nice to move most services over.

johanib added a commit that referenced this pull request Nov 5, 2025
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
@johanib
Copy link
Contributor Author

johanib commented Nov 5, 2025

IRL @johanib convinced me to not big bang move all services to the new Runtime version. I then suggested to add some nuance to the instructions found in the PHPDoc

Done.

Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
@johanib johanib merged commit d76210f into upgrade-84 Nov 5, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Delivered in PHP development Nov 5, 2025
@johanib johanib deleted the feature/twig_di branch November 5, 2025 08:07
@baszoetekouw baszoetekouw added this to the 7.0.0 milestone Feb 2, 2026
@baszoetekouw baszoetekouw moved this from Delivered to Ready for release in PHP development Feb 2, 2026
johanib added a commit that referenced this pull request Feb 9, 2026
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
johanib added a commit that referenced this pull request Feb 10, 2026
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
johanib added a commit that referenced this pull request Feb 10, 2026
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
johanib added a commit that referenced this pull request Feb 25, 2026
Prior to this change, it was not possible to inject dependencies into Corto in a modern way. Corto pulled all dependencies from the Symfony service container itself.
This caused issues, because it is no longer possible to pull twig from the service container in Symfony 6.4.

This change introduces a DiContainerRuntime, which can be used to inject dependencies into Corto. This was not possible using the DiContainer, because the DiContainer is constructed during bundle bootstrapping, where DI is not available. It is not possible to move it from there, as it is required by various constructions in the bootstapping process.
The DiContainerRuntime is injected into Corto after bootstrapping, but before the request is handled.

#1874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready for release

Development

Successfully merging this pull request may close these issues.

Upgrade to symfony 6.4

3 participants