Problem/Motivation

In Symfony 3.3 the DependencyInjection component received a lot of attention and new features including autowiring and private services by default. Drupal's container and YamlFileLoader have not changed much since 8.0.0 and lack these new features. This means that:

  • We are steadily getting less and less like a Symfony application
  • Drupal developers have to type more and know more arcane Drupalisms and the internet is less helpful because the Symfony examples don't work
  • We risk becoming so incompatible that we won't be able to leverage Symfony container code

To read about the new features in Symfony 3.3 - https://symfony.com/doc/current/service_container/3.3-di-changes.html

Proposed resolution

Work on bring Drupal 8 the same or similar feature set:

Remaining tasks

Define all the tasks and discuss possibilities.

User interface changes

None

API changes

@todo

Data model changes

None

Release notes snippet

@todo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Whilst the plan is not yet ready for review tagging to make other framework managers aware of the effort and hopefully to encourage contribution.

alexpott’s picture

Title: New features from Symfony 3.3 into our container » Bring new features from Symfony 3.3 into our container
jparkinson1991’s picture

These changes can not be implemented quick enough!

Whilst i think it is enabled by default by virtue of using the dependency injection component >3.3 it is the Drupal yaml wrappers etc that stop this functionality being available.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aaronbauman’s picture

chi’s picture

Issue summary: View changes
chi’s picture

Drupal's container and YamlFileLoader have not changed much since 8.0.0 and lack these new features

The reason of maintaining own Yaml loader was to avoid dependency on Symfony Config component. Maybe today we can revise that decision?

fgm’s picture

The Config component is quite a big can of worms on its own : what would it actually gain us ? Do you really want to add SF-style config trees on top of our own CMI ?

martin107’s picture

I wanted to answer "how would this affect performance"

In short dev may be a improvement, production no so much. Me quietly giggling -- the last paragraph could be written with Drupal in mind.

https://symfony.com/doc/current/service_container/3.3-di-changes.html

What about Performance¶
Symfony is unique because it has a compiled container. This means that there is no runtime performance impact for using any of these features. That's also why the autowiring system can give you such clear errors.

However, there is some performance impact in the dev environment. Most importantly, your container will likely be rebuilt more often when you modify your service classes. This is because it needs to rebuild whenever you add a new argument to a service, or add an interface to your class that should be autoconfigured.

In very big projects, this may be a problem. If it is, you can always opt to not use autowiring. If you think the cache rebuilding system could be smarter in some situation, please open an issue!

aaronbauman’s picture

Issue summary: View changes
chi’s picture

Do you really want to add SF-style config trees on top of our own CMI ?

We don't have to use it. Just add symfony/config as a dependency and use the original Yaml loader. This would help us to resolve issues like following.

jparkinson1991’s picture

Im with Chi on this. We can Drupalise this all we want but there is a real fundamental issue we're all missing here.

We (the core dev's) chose to use symfony/dependency-injection. symfony/dependency-injection as a package has a set of dependencies and development dependencies (symfony/config being one of those). It is not for us to pick and choose which depdencies we want to use, and which we want to exclude. A dependency is a dependency is a dependency. If we want to use the dependency injection component, then we have to accept and include of all it's dependencies where required. If we are not happy with the dependencies of a package then we must choose another package to use in its place.

By doctoring underlying components you're causing headaches for all of us developers.
Common scenario:

  • I review symfony docs for how and what can be done with a component
  • I implement according to symfony docs
  • Doesn't work
  • Review documentation/check implementation x20
  • Dig around in Drupal core.. find an undocumentated Drupalism has reduced component functionality..

I think from the above you can feel my frustrations. This needs to be sorted out.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bradjones1’s picture

andypost’s picture

Title: Bring new features from Symfony 3.3 into our container » Bring new features from Symfony 3/4/5 into our container
Version: 9.3.x-dev » 9.4.x-dev

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

longwave’s picture

Title: Bring new features from Symfony 3/4/5 into our container » Bring new features from Symfony 3/4/5/6 into our container
Issue summary: View changes
andypost’s picture

Version: 9.5.x-dev » 10.1.x-dev

It does not fit in 9.5

dieterholvoet’s picture

Since we're adding interface aliases to core modules, would it make sense to start doing the same for contrib modules? And if so, for all services including things like event subscribers, or just services that are useful to other modules?

donquixote’s picture

Since we're adding interface aliases to core modules, would it make sense to start doing the same for contrib modules?

To extend this question:

I see for now, in core, we are keeping the string service ids, and are only adding interface names as aliases.
For existing services this makes sense, because changing the existing service name would break BC.

In symfony, it is possible to use a class name instead of a custom service id.
This even seems to be the standard now, according to https://symfony.com/doc/current/service_container.html#creating-configur....

Automatic Service Loading in services.yaml

The documentation assumes you're using the following service configuration, which is the default config for a new project:

So the question is, should we adopt or allow using class names as service names in our conventions for contrib and for new services in core, or should we stick to custom string ids?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

fgm’s picture

Beyond autowiring, we have a small issue in the URL generator not respecting the Unicode property of route regexps #3369925: Support Unicode regular expressions in routes, from Symfony 4.3.

chi’s picture

Title: Bring new features from Symfony 3/4/5/6 into our container » Bring new features from Symfony 3/4/5/6/7 into our container

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.