As I understand it, DI just means that you inject and objects upon with the subject class depends via a method (which can include the constructor).
class Foo
{
private $dependency1;
private $dependency2;
public function __construct(Dependency1 $dependency1)
{
$this->dependency1 = $dependency1;
}
public setDependency2(Dependency2 $dependency2)
{
$this->depenedency2 = $dependency2;
}
}
$d1 = new Dependency1();
$foo = new Foo($d1);
$foo->setDependency2(new Dependency2());
Note that you can use either instantiation technique as appropriate to your needs/preferences, e.g. the following would work just as well:
$foo = new Foo(new Dependency1());
$d2 = new Dependency2();
$foo->setDependency2($d2);
There are arguments for and against injecting the dependencies via the constructor or a setter method. I generally start with the constructor and move it to a setter if it seems better that way.