Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Autowiring

Autowiring, or auto-wiring, 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 reduces boilerplate code, enhances type usage and makes refactoring easier.

<?php

    class Renderer {
        private View $view;
    
        function __construct(View $view) {
            $this->view = $view;
        }
    }

?>

Documentation

See Also