Implement Interface at run-time PHP

257 Views Asked by At

Hi Im working on a login application using slim and cartalyst\sentinel. When i create new instance of sentinel reminder $reminder = new Cartalyst\Sentinel\Reminders\IlluminateReminderRepository; it give an error to implement UserRepositoryInterface error __construct() must implement interface Cartalyst\Sentinel\Users\UserRepositoryInterface.

My Question is how can i implement an interface on run-time in php.

Whereas at above i used activation class which also implement an interface in src code like class IlluminateActivationRepository implements ActivationRepositoryInterface but it do not give error.

This below activation class is working fine.

$activation = (new Cartalyst\Sentinel\Activations\IlluminateActivationRepository)->create($user);
1

There are 1 best solutions below

0
On BEST ANSWER

Ok i solved by this supplying user repository object.

$users = $app->container->sentinel->getUserRepository();

 $reminder =  new Cartalyst\Sentinel\Reminders\IlluminateReminderRepository ( $users );