Autowiring¶
Autowiring is the ability of the framework to inject dependencies, based on the constructor signature.
Autowiring is based on types.
Several PHP frameworks offer autowiring : Laravel, Netter, Slim, Symfony…
<?php
class Renderer {
private View $view;
function __construct(View $view) {
$this->view = $view;
}
}
?>
See also PHP OOP Autoloading, What is autoloading in PHP, Defining Services Dependencies Automatically (Autowiring)
Related : Dependency Injection, Type System