title: Laravel 8 Binding Interfaces To Implementations not working
body: <p>I followed <a href="https://laravel.com/docs/8.x/container#binding-interfaces-to-implementations" rel="nofollow noreferrer">https://laravel.com/docs/8.x/container#binding-interfaces-to-implementations</a> to implement Interface</p>
  <p>I created Service provider</p>
  <pre class="lang-php prettyprint-override"><code>namespace App\Providers;
  
  use Illuminate\Support\ServiceProvider;
  
  class OpenApiOperationProvider extends ServiceProvider
  {
      /**
       * Register services.
       *
       * @return void
       */
      public function register()
      {
          $this-&gt;app-&gt;bind(\App\oam\lib\OperationInterface::class, function ()
          {
              exit(&quot;yess,it workeed&quot;);
          });
      }
  
      /**
       * Bootstrap services.
       *
       * @return void
       */
      public function boot()
      {
          //
      }
  }
  
  </code></pre>
  <p>and I have controller</p>
  <pre class="lang-php prettyprint-override"><code>namespace App\Http\Controllers;
  
  class Docs extends Controller
  {
      public function show(\App\oam\path\token\post\CreateToken $dd)
      {
          dd($dd);
          exit;
      }
  }
  
  </code></pre>
  <p>Create Token class which implements \App\oam\lib\OperationInterface interface.</p>
  <pre class="lang-php prettyprint-override"><code>namespace App\oam\path\token\post;
  
  use App\oam\component\schema\Token;
  use App\oam\component\response\Error;
  use App\oam\lib\Operation;
  
  /**
   * Schema location #/token/create/post
   * Operation path POST /token/create
   *
   * @property body\CreateTokenBody $rb
   * @property Token $res200 http code 200 class
   * @property Error $resdefault http code default class
   * @method Token|Error getResponse() get active response
   */
  class CreateToken extends Operation implements \App\oam\lib\OperationInterface
  {
      public function __construct()
      {
          parent::__construct('post', '/token/create', 'createToken');
          $this-&gt;registerRequestBody('\App\oam\path\token\post\body\CreateTokenBody');
          $this-&gt;registerResponse('200','\App\oam\component\schema\Token');
          $this-&gt;registerResponse('default','\App\oam\component\response\Error');
      }
  }
  
  </code></pre>
  <p>But the controller constructs CreateToken without service provider bind.
  But if I do bind directly to class, then it works</p>
  <pre class="lang-php prettyprint-override"><code>public function register()
  {
      $this-&gt;app-&gt;bind(\App\oam\path\token\post\CreateToken::class, function ()
       {
           exit(&quot;yes, it worked&quot;);
         });
      }
  
  </code></pre>
  <p>Also I can't to get working contextual binding</p>
  <pre class="lang-php prettyprint-override"><code>public function register()
  {
      $this-&gt;app-&gt;when(\App\Http\Controllers\Docs::class)-&gt;needs(\App\oam\path\token\post\CreateToken::class)-&gt;give(function ()
      {
          exit(&quot;yes, it worked&quot;);
      });
  }
  </code></pre>