title: Laravel - Composer unable to find the service provider class
body: <p>I have been creating a <a href="https://github.com/kamranahmedse/laravel-censor" rel="nofollow">Laravel package</a> (a Middleware). My folder structure looks like the following:</p>
  
  <pre><code>laravel-censor/
      config/
          sensor.php
      src/
          CensorMiddleware.php
          LaravelCensorServiceProvider.php
      composer.json
  </code></pre>
  
  <p>And the content of <code>composer.json</code> is:</p>
  
  <pre><code>{
      "name": "kamranahmedse/laravel-censor",
      ...
      ...
      "require": {
          "php" : "&gt;=5.4.0",
          "laravel/framework": "^5.1.11"
      },
      "autoload": {
          "psr-4": {
              "KamranAhmed\\LaravelCensor\\": "src/"
          }
      },
      "minimum-stability": "stable"
  }
  </code></pre>
  
  <p>I have released it to <a href="https://packagist.org/packages/kamranahmedse/laravel-censor" rel="nofollow">packagist</a> and can be found through <a href="https://github.com/kamranahmedse/laravel-censor" rel="nofollow">github</a>. Now after installing</p>
  
  <pre><code>composer require kamranahmedse/laravel-censor
  </code></pre>
  
  <p>When I add the package's service provider to <code>providers</code> array in <code>config/app.php</code></p>
  
  <pre><code>KamranAhmed\LaravelCensor\LaravelCensorServiceProvider::class
  </code></pre>
  
  <p>And run</p>
  
  <pre><code>php artisan vendor:publish
  </code></pre>
  
  <h2>The problem</h2>
  
  <p>It is unable to find the service provider class and throws a class not found exception. Can any body please point out what am I doing wrong here? Why is composer not able to autoload this class?</p>
  
  <p>I have been looking into this for over an hour now and unable to figure out the problem that why composer isn't autoloading this class. Also, I have checked and the namespaces and class names are all correct:</p>
  
  <pre><code># LaravelCensorServiceProvider.php
  namespace KamranAhmed\LaravelCensor;
  ...
  class LaravelCensorServiceProvider extends ServiceProvider
  { ... }
  </code></pre>
  
  <h2>Solution</h2>
  
  <p>It turned out that composer had some cache. Running <code>php artisan clear-compiled</code> after clearing the composer cache <code>composer clear</code> did the trick.</p>