6 months ago

Passing an instance but missing bindings

Posted 6 months ago by dubbeltje


I am struggling with the following.

I am having a class which has 2 dependencies:

class A {

public function __construct(B $b, C $c)
	$this->b = $b;
        $this->c = $c

Now somewhere else in my code I am passing an instance of a like so;

$configObject = new ConfigObject()->with(new A);

Now A has two dependencies. But I don't want to add the dependencies but I want them to be resolved from the dependency container. How can I go about this?

I'm running on Laravel 6.x

Thanks so much.

Please sign in or create an account to participate in this conversation.