Skip to content

[2.1] Autowiring #836

@schmittjoh

Description

@schmittjoh

Autowiring is a nice replacement for the removed interface injection. It is also mainly useful for controllers:

class MyController
{
    /**
     * @Autowire
     * @var Symfony\Component\HttpFoundation\Request
     */
    private $request;
}

The dependency injection container would automatically inject the "request" service into MyController::$request using property injection. The benefit is again less code to write (or configuration), faster development, and no container dependency in the controller. However, in contrast to method injection services would not be lazy-loaded.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions