Autowiring¶
Autowiring is the ability of the framework to inject dependencies, based on the constructor signature.
Autowiring is based on types, in the signature of the controller.
Autowiring is commonly used in dependency injection, DI containers.
Autowiring reduce boilerplate code, enhance type usage and make refactoring easier.
<?php
class Renderer {
private View $view;
function __construct(View $view) {
$this->view = $view;
}
}
?>
See also https://php-di.org/doc/autowiring.html, https://symfony.com/doc/current/service_container/autowiring.html
Related : Dependency Injection, Type System, Constructor, Boilerplate, Type System,
Related packages : nette/di, php-di/php-di