title: Attempting to bind Guzzle Curl Client to Laravel's Service Container -- then Type Hint the Client Fails when attempting to __construct()
body: <p>So I figured I'd try to actually use this fancy IoC container in Laravel. I'm starting with Guzzle but I cannot get it to work. Perhaps there is a gap in my understanding. I really appreciate any help here. </p>
  
  <p>so I've got a class for connecting to a RESTful Api. Here is a sample from it:</p>
  
  <pre><code>    use GuzzleHttp\Exception\BadResponseException;
      use GuzzleHttp\Client;
      use GuzzleHttp\Subscriber\Oauth\Oauth1;
  
  class EtApi {
      //you can pass in the model if you wanna
      //protected $model;
  
      //client Id
      protected $clientId;
  
      //client secret
      protected $clientSecret;
  
      //base_uri
      protected $getTokenUri;
  
      protected $client;
  
      //build
      function __construct(Client $client)
      {
          $this-&gt;client = $client;
          $this-&gt;clientId = 's0m3R4nd0mStr1nG';
          $this-&gt;clientSecret = 's0m3R4nd0mStr1nG';
          $this-&gt;getTokenUri = 'https://rest.api/requestToken';
          $this-&gt;accessToken = $this-&gt;getToken($this-&gt;clientId, $this-&gt;clientSecret, $this-&gt;getTokenUri);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I've successfully installed and used Guzzle by manually newing it up inside of methods like $client = new Client(); but that's not very DRY and it's not the right way of doing things. So I created a ServiceProvider at app\Providers\GuzzleProvider.php. I made sure this was registered in app/config/app.php under <code>$providers = ['App\Providers\GuzzleProvider']</code>. Here is the Provider Code:</p>
  
  <pre><code>    &lt;?php namespace App\Providers;
  
  use Illuminate\Support\ServiceProvider;
  use GuzzleHttp\Client;
  use GuzzleHttp\Subscriber\Oauth\Oauth1;
  
  class GuzzleProvider extends ServiceProvider {
  
      /**
       * Bootstrap the application services.
       *
       * @return void
       */
      public function boot()
      {
          //
      }
  
      /**
       * Register the application services.
       *
       * @return void
       */
      public function register()
      {
          //
          $this-&gt;app-&gt;bind('Client', function () {
              return new Client;
          });
      }
  
  }
  </code></pre>
  
  <p>So when I try to access my EtApi methods that load fails during the instantiation (__construct) with the following error.</p>
  
  <pre><code>ErrorException in EtApi.php line 23:
  Argument 1 passed to App\EtApi::__construct() must be an instance of GuzzleHttp\Client, none given, called in /home/vagrant/webdocs/et_restful_test/app/Http/Controllers/EtConnectController.php on line 23 and defined
  </code></pre>
  
  <p>Do any of you Laravel Masters have any idea why I can't bind Guzzle using this code and Laravel's magic will just inject the obj into the constructor? The [docs<a href="http://laravel.com/docs/5.0/container" rel="noreferrer">1</a> say I should be able to do this. I must be missing something. Thank You!</p>