vendredi 27 octobre 2017

Laravel Tinker creating new object that have constructer as an interface

I am trying to use Laravel Tinker to create a new object that have a constructer as an interface. MyClass.php

class MyClass{
 public function __construct(ApiInterface $APIloader)
    {
        $this->APIloader = $APIloader;
    }
}

ApiInterface.php

interface ApiInterface {
    ..
    ..
}

I wanted to test my classes in tinker so what i have done is that:

php artisan tinker
>> $a = new App\MyClass(new App\ApiInterface);

The error that i got is :

PHP Fatal error:  Class 'App\ApiInterface' not found in eval()'d code on line 1

The tinker is not allow me todo that i feel like the tinker does not recognize an interface as a class

Any idea ?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire