I'm trying to do automatic resolution of dependencies.
I've got this code in my routes.php file:
App::singleton('Client', function($app)
{
$client = App::make('ClientInterface');
$client = $client->getCurrent();
return $client;
});
App::singleton('AlerterInterface', function($app)
{
$replacers = array( new ItemReplacer );
$messager = new SessionAlerter($prefix='alerter_machine', $replacers);
return $messager;
});
Then, I've got this in a controller:
public function __construct( Shop\Product $product, AlerterInterface $alerter, Client $client )
Oddly, the AlerterInterface resolves, but the Client does not. and I get this error:
ReflectionException
Class Client does not exist
I can load the client just fine if I take it out of __construct's parameters and put it into the method, like this:
$this->client = App::make('Client');
Any idea what's going on?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community