Use native Symfony YamlLoader + Config

Created on 4 February 2020, almost 5 years ago
Updated 29 December 2023, 12 months ago

Problem/Motivation

Symfony has gotten many handy features over the year to make configuring services much easier. Things like:
- _defaults where settings apply by default to all services in the file
- _instanceof where you can for instance set tags for all classes implementing a specific interface
- public where you can easily make everything private by default
- resource loading where you can set a path and namespace and automatically load all services while taking defaults into account
- aliasing services

This makes it so much easier to maintain modules and speeds up development as you can simply create services without the need for configuration.

Proposed resolution

The thing holding Drupal back is the custom YamlFileLoader that is once copied from the Symfony repository. My proposed solution is to remove this copy and simply load the actual YamlFileLoader from the symfony/config package. Doing this has the following advantages:

- Above features are immediately available
- Less maintenance since another reliable component is used

Also I've moved the container loader to it's own separate function by example of Symfony Framework.

Remaining tasks

I'll submit a patch that contains these changes and I'll need to await proper testing by the Drupal Test bot to see if there are unexpected breaking changes.

Notes

For now I had to add symfony/config to the root composer.json as the core/composer.json seems to be ignored as it follows the "drupal/core" depenency which does not contain symfony/config right now. This would need to be moved later.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡³πŸ‡±Netherlands slootjes

Live updates comments and jobs are added and updated live.
  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡ΊπŸ‡ΈUnited States effulgentsia

    Symfony has gotten many handy features over the year to make configuring services much easier. Things like:
    ...
    - resource loading where you can set a path and namespace and automatically load all services while taking defaults into account

    Package Manager (a sub-module of Automatic Updates) currently uses that and we're working on getting that into core (see 🌱 Drupal 10 Core Roadmap for Automatic Updates Active if you're interested in the roadmap of that). So we opened πŸ“Œ Add symfony/config to core's dependencies for package_manager Closed: duplicate to discuss/review adding symfony/config as a core dependency. That's a smaller step than the rest of what this issue is doing, so I wonder if it makes sense to try to get that one in first, and then continue here with just the proposed changes to YamlFileLoader.

Production build 0.71.5 2024