T
T
thorii2016-11-05 14:55:45
PHP
thorii, 2016-11-05 14:55:45

Can a DI container inject classes into the constructor that are not declared in the container?

Let's say

class Expample {
function __construct(Responser $responser) {}
}

$di = new DI();
$di->set('expample', 'Example');

The Responser class is not registered with the container. Does Di have the right to look for a Responser outside of itself and, if found successfully, inject it into the constructor? Or should he look for the Responser only inside himself, in case of absence, throw an exception?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitriy, 2016-11-05
@thorii

container.thephppleague.com/auto-wiring

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question