title: ReflectionException Class does not exist happens on git branch switch Laravel
body: <p>So I read like 100 post about this before deciding on creating this issue. </p>
  
  <p>This problem is actually very specific and it's 100% reproducable. </p>
  
  <p>I created a git branch lets call it <code>storeUpdate</code>, and in this branch I created a file called </p>
  
  <pre><code>app/Http/Controllers/Admin/BatchUpdateStoresController.php
  </code></pre>
  
  <p>which has the following:</p>
  
  <pre><code>namespace App\Http\Controllers\Admin;
  
  use App\Http\Requests;
  use Illuminate\Http\Request;
  use App\Http\Controllers\Controller;
  use App\Repositories\BatchUpdateStores;
  
  class BatchUpdateStoresController extends Controller
  </code></pre>
  
  <p>and I've added it to the routes.php file:</p>
  
  <pre><code>app/Http/routes.php|214| $api-&gt;put('stores', 'Admin\BatchUpdateStoresController@update');
  app/Http/routes.php|215| $api-&gt;post('stores', 'Admin\BatchUpdateStoresController@upload');
  </code></pre>
  
  <p>also the relevant part in my composer file:</p>
  
  <pre><code>"autoload": {
      "classmap": [
          "database"
      ],
      "psr-4": {
          "App\\": "app/"
      }
  },
  "autoload-dev": {
      "classmap": [
          "tests/TestCase.php",
          "tests/Helpers/",
          "tests/Traits/"
      ]
  },
  </code></pre>
  
  <p>However, when I switch the branch to another git branch, and I try to run <code>php artisan</code>, I get this error:</p>
  
  <blockquote>
    <p>[ReflectionException]   Class
    App\Http\Controllers\Admin\BatchUpdateStoresController does not exist</p>
  </blockquote>
  
  <p>I find the above error interesting, as indeed that file doesn't exist (notice the actual file is <code>app/Http/Controllers/Admin/BatchUpdateStoresController.php</code>, so <code>app</code> != <code>App</code>, but aren't I already taking care of this in the <code>psr-4</code> section of my composer.json file? </p>
  
  <p>Ideas?</p>
  
  <h1>what i tried</h1>
  
  <p>all the usual stuff including:</p>
  
  <ul>
  <li><code>composer dump-autoload</code></li>
  <li><code>composer update</code></li>
  <li><code>composer update --no-scripts</code></li>
  <li><code>php artisan cache:clear</code></li>
  <li><code>php artisan api:clear</code></li>
  <li><code>php artisan route:clear</code></li>
  </ul>
  
  <h1>stacktrace</h1>
  
  <pre><code>ReflectionException: Class App\Http\Controllers\Admin\BatchUpdateStoresController does not exist in /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php:749 
  Stack trace: #0 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(749): ReflectionClass-&gt;__construct('App\\Http\\Contro...') 
  #1 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Container/Container.php(644): Illuminate\Container\Container-&gt;build('App\\Http\\Contro...', Array) 
  #2 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container-&gt;make('App\\Http\\Contro...', Array) 
  #3 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(320): Illuminate\Foundation\Application-&gt;make('App\\Http\\Contro...') 
  #4 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(182): Dingo\Api\Routing\Route-&gt;makeControllerInstance() 
  #5 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(165): Dingo\Api\Routing\Route-&gt;mergeControllerProperties() 
  #6 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Route.php(144): Dingo\Api\Routing\Route-&gt;setupRouteProperties(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) 
  #7 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(652): Dingo\Api\Routing\Route-&gt;__construct(Object(Dingo\Api\Routing\Adapter\Laravel), Object(Illuminate\Foundation\Application), Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) 
  #8 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(714): Dingo\Api\Routing\Router-&gt;createRoute(Object(Illuminate\Routing\Route)) #9 /Users/Shared/dev/php/toters-api/vendor/dingo/api/src/Routing/Router.php(744): Dingo\Api\Routing\Router-&gt;getRoutes() 
  #10 /Users/Shared/dev/php/toters-api/bootstrap/cache/routes.php(17): Dingo\Api\Routing\Router-&gt;setAdapterRoutes(Array) 
  #11 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(58): require('/Users/Shared/d...') 
  #12 [internal function]: Illuminate\Foundation\Support\Providers\RouteServiceProvider-&gt;Illuminate\Foundation\Support\Providers\{closure}(Object(Illuminate\Foundation\Application)) 
  #13 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(808): call_user_func(Object(Closure), Object(Illuminate\Foundation\Application)) 
  #14 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(757): Illuminate\Foundation\Application-&gt;fireAppCallbacks(Array) 
  #15 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application-&gt;boot() 
  #16 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders-&gt;bootstrap(Object(Illuminate\Foundation\Application)) 
  #17 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application-&gt;bootstrapWith(Array) 
  #18 /Users/Shared/dev/php/toters-api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(113): Illuminate\Foundation\Console\Kernel-&gt;bootstrap() 
  #19 /Users/Shared/dev/php/toters-api/artisan(35): Illuminate\Foundation\Console\Kernel-&gt;handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #20
  </code></pre>
  
  <p>h2. udpdate</p>
  
  <p>based on <a href="https://stackoverflow.com/users/8256132/eder-soares">Edwards</a> <a href="https://stackoverflow.com/a/49060474/766570">answer</a> the following worked:</p>
  
  <ol>
  <li>if you go to the git branch that doesn't have that class.. by definition, <em>any</em> <code>php artisan</code> will blow up, so then you already don't have access to some php artisan commands such as <code>php artisan route:clear</code></li>
  <li>therefore, go back to the original branch that has the above class and make sure <code>php artisan</code> runs</li>
  <li>run <code>php artisan route:clear</code></li>
  <li>switch branches</li>
  <li>profit</li>
  </ol>