Add support for autowiring to controller methods

Created on 1 November 2023, 10 months ago

Problem/Motivation

Symfony supports auto-wiring of controller methods. For example:

class SomeController {
  public function someMethod(ConfigFactoryInterface $configFactory) {
    // Here $configFactory is autowired/injected from the container.
  }
}

Because we have our own version of controller resolver, we're missing the upstream changes that support this.

This simplifies controllers as they no longer need as much boiler-plate for constructor injection.

It also allows more granular dependency injection for controller classes with multiple methods. If a dependency is only needed for one method, there is no need to inject that service into the constructor. Constructor injection can be reserved for services that span multiple methods. This will then result in leaner and easier to maintain code and an improved DX.

Steps to reproduce

Proposed resolution

Add support for auto-wiring of controller methods via arguments by mirroring the updated logic from upstream.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
RoutingΒ  β†’

Last updated 8 days ago

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024