rdlowrey / auryn

IoC Dependency Injector
MIT License
722 stars 65 forks source link

Injection definition required for non-concrete parameter $interface of type Http\Request #85

Closed HassanAlthaf closed 9 years ago

HassanAlthaf commented 9 years ago

Hey, I get that error when I had this code:

$injector->alias('Http\Response', 'Http\HttpResponse'); $injector->share('Http\HttpRequest'); $injector->define('Http\HttpRequest', [ ':get' => $_GET, ':post' => $_POST, ':cookies' => $_COOKIE, ':files' => $_FILES, ':server' => $_SERVER, ]);

$injector->alias('Http\Request', 'Http\HttpRequest'); $injector->share('Http\HttpResponse');

However, when I use an old version of Auryn, it works perfectly fine! I bet this is a bug.

J7mbo commented 9 years ago

Could you provide the relevant constructor / method signatures of the objects you're attempting to create, and explain what you're trying to do?

rdlowrey commented 9 years ago

Yes, a simple reproduce script would go a long way to diagnosing any potential issue. It would be very helpful if you could provide one :)

HassanAlthaf commented 9 years ago

I use it like this: namespace App;

use Http\Request; use Http\Response;

class Foo { private $request; private $response; public function __construct(Request $request, Response $response) { $this->response = $response; $this->request = $request; }

  public function do()
  {
     $username = $this->request->getParameter('username');
  }

}

HassanAlthaf commented 9 years ago

That is how I use it, and it generates that error when the class is instantiated.

HassanAlthaf commented 9 years ago

This problem is fixed when I use an old version of Auryn, so that is what I'm using right now.

VeeeneX commented 9 years ago

@HassanAlthaf And which version are you using right now?

VeeeneX commented 9 years ago

@HassanAlthaf Try this

use \Http\Request;
use \Http\Response;
rdlowrey commented 9 years ago

I can't diagnose anything from the code samples provided. Please add a code snippet demonstrating actual Auryn usage that gives an error where a different result is expected.

rdlowrey commented 9 years ago

Closing as there's been no activity and no reproduce code ...