The dependency injection is a well-established software technique that deals with the problem of object dependencies, allowing us to write loosely coupled classes. While the pattern itself has been around for quite some time, the PHP ecosystem hasn't really picked it up until major frameworks such as Symfony started implementing it. Nowadays, it is a de facto standard for anything other than trivial types of application. The whole dependency problem is easily observed through a simple example:
<?php
class Customer
{
protected $name;
public function loadByEmail($email)
{
$mysqli = new mysqli('127.0.0.1', 'foggy', 'h4P9niq5', 'sakila');
$statement = $mysqli->prepare('SELECT * FROM customer WHERE email = ?');
$statement->bind_param('s', $email...