Ok, problem solved, this was just me not understanding. I didn't want to bind to a type like "app.myservice" because the purpose of the bindings is for dependency injection. This worked exactly how the documentation describes deferred providers, just put the full type in the array returned from provides()
, so for the above example, my whole service provider looks like:
/**
* Whether or not to defer the loading of this service
* provider until it's needed
*
* @var boolean
*/
protected $defer = true;
/**
* Register bindings with the IoC container
*
* @return void
*/
public function register() {
$this->app->bind('League\Flysystem\Filesystem', function($app) {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
'username' => $app['config']->get('services.rackspace.username'),
'apiKey' => $app['config']->get('services.rackspace.key'),
));
$store = $client->objectStoreService('cloudFiles', 'SYD');
$container = $store->getContainer($app['config']->get('services.rackspace.container'));
return new Filesystem(new Adapter($container));
});
}
/**
* The services that this service provider registers
*
* @return array
*/
public function provides() {
return ['League\Flysystem\Filesystem'];
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community