timtom
3 months ago
228
2
Laravel

Binding An Interface To An Implementation

Posted 3 months ago by timtom

Hello,

I build an interface to an implementation like this :

App::bind('UserRepositoryInterface', 'DbUserRepository');

And it is working when i use this in controller :

public function __construct(UserRepositoryInterface $repository)

But i would like to use the same solution in another class with his construct method but i got error if i don't give the parameter when the class is init with :

$class = new ClassName();

Someone already got this problem ?

Thanks

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