title: Binding the dependency of a Laravel Service Provider inside the provider itself?
body: <p>I am just starting to get the hang of Service Providers and the IoC container, however one thing is confusing me. I have a SpamServiceProvider that requires two other classes to function. However one of those classes, InvalidKeywords, has a array $blacklist parameter which needs to be passed to its constructor. </p>
  
  <p>If I register that class in the AppServiceProvider and pass in the $blacklist array, everything works fine. However, if I try to bind the class in the SpamServiceProvider instead it will not inject the $blacklist into InvalidKeywords constructor.</p>
  
  <p>So I guess my question is why is this? And is there a way to keep bindings like this together in a single container or do I simply have to bind InvalidKeywords inside the AppServiceProvider? </p>
  
  <p>This works</p>
  
  <pre><code>class SpamServiceProvider extends ServiceProvider
  {
  
  /**
   * Indicates if loading of the provider is deferred.
   *
   * @var bool
   */
  protected $defer = true;
  
  /**
   * Bootstrap services.
   *
   * @return void
   */
  public function boot()
  {
      //
  }
  
  /**
   * Register services.
   *
   * @return void
   */
  public function register()
  {
  
      $this-&gt;app-&gt;bind(SpamManager::class, function ($app) {
          return new SpamManager(new InvalidKeywords, new RepeatedCharacters);
      });
  }
  
  }
  
  
  class AppServiceProvider extends ServiceProvider
  {
  /**
   * Register any application services.
   *
   * @return void
   */
  public function register()
  {
      $this-&gt;app-&gt;bind(InvalidKeywords::class, function ($app) {
          return new InvalidKeywords(config('spam.blacklist'));
      });
  }
  }
  </code></pre>
  
  <p>This does not work</p>
  
  <pre><code>class SpamServiceProvider extends ServiceProvider
  {
  
  /**
   * Indicates if loading of the provider is deferred.
   *
   * @var bool
   */
  protected $defer = true;
  
  /**
   * Bootstrap services.
   *
   * @return void
   */
  public function boot()
  {
      //
  }
  
  /**
   * Register services.
   *
   * @return void
   */
  public function register()
  {
  
      $this-&gt;app-&gt;bind(InvalidKeywords::class, function ($app) {
          return new InvalidKeywords(config('spam.blacklist'));
      });
  
      $this-&gt;app-&gt;bind(SpamManager::class, function ($app) {
          return new SpamManager(new InvalidKeywords, new RepeatedCharacters);
      });
  }
  }
  </code></pre>