title: Getting "class does not exist" in Laravel 5.x
body: <p>I'm getting the error: <code>Class App\Http\Controllers\TranslatorService does not exist</code> regardless of the namespace being set in the controller correctly and the file being in the correct location.</p>
  
  <p>route.php:</p>
  
  <pre><code>Route::group(['prefix' =&gt; 'api', 'middleware' =&gt; 'response-time'], function     () {
      Route::group(['prefix' =&gt; 'v1'], function () {
          Route::get('/', function () {
              App::abort(404);
          });
  
          Route::resource('accounts', 'AccountController');
      });
  
      Route::group(['prefix' =&gt; 'v2'], function () {
          Route::get('/', function () {
              App::abort(501, 'Feature not implemented');
          });
      });
  });
  </code></pre>
  
  <p><code>AccountController.php</code> under <code>app/ComdexxSolutions/Http/Controllers</code> is a standard skeleton controller.</p>
  
  <p><code>TranslationService.php</code> is under the same path as <code>AccountController</code> and looks like:</p>
  
  <pre><code>&lt;?php
  
  namespace ComdexxSolutions\Http\Controllers;
  
  use InvalidArgumentException;
  use RuntimeException;
  use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  
  class TranslatorService
  {
      /**
       * Returns a class name base on a resource mapping.
       * The mapping comes from a config file (api.php).
       *
       * Example: `users` should return `\App\Models\User`
       *
       * @param string $resource
       * @return string
      * @throws NotFoundHttpException
       */
      public function getClassFromResource($resource)
      {
          // This is the models namespace
          $modelsNamespace = Config::get('api.models_namespace',     Config::get('api.app_namespace'));
  
          // This array contains mapping between resources and Model classes
          $mapping = Config::get('api.mapping');
  
          if (!is_array($mapping)) {
              throw new RuntimeException('The config api.mapping needs to be an array.');     
           }
  
          if (!isset($mapping[$resource])) {
               throw new NotFoundHttpException;
           }
  
          return implode('\\', [$modelsNamespace, $mapping[$resource]]);
      }
  
      /**
       * Returns a command class name based on a resource mapping.
       *
       * Examples:
       *     - getCommandFromResource('users', 'show') returns     \App\Commands\UserCommand\ShowCommand
       *     - getCommandFromResource('users', 'index', 'groups') returns     \App\Commands\UserCommand\GroupIndexCommand
       *
       * @param string $resource
       * @param string $action
       * @param string|null $relation
       * @return string
       * @throws NotFoundHttpException
       */
       public function getCommandFromResource($resource, $action, $relation = null)
      {
          $namespace = Config::get('api.app_namespace');
          $mapping = Config::get('api.mapping');
  
          // If the mapping does not exist, we consider this as a 404 error
          if (!isset($mapping[$resource])) {
              throw new NotFoundHttpException('The resource [' . $resource . '] is not mapped to any Model.');
          }
  
          $allowedActions = ['index', 'store', 'show', 'update', 'destroy'];
  
          if (!in_array($action, $allowedActions)) {
              throw new InvalidArgumentException('[' . $action . '] is not a valid action.');
          } 
  
          // If we have a $relation parameter, then we generate a command based on it
          if ($relation) {
              if (!isset($mapping[$relation])) {
                  throw new NotFoundHttpException('The resource [' . $resource . '] is not mapped to any Model.');
              }
  
              $command = implode('\\', [
                  $namespace,
                  'Commands',
                  $mapping[$resource] . 'Command',
                  ucfirst($mapping[$relation]) . ucfirst($action) . 'Command'
              ]);
          } else {
              $command = implode('\\', [
                  $namespace,
                  'Commands',
                  $mapping[$resource] . 'Command',
                  ucfirst($action) . 'Command'
               ]);
           }
  
          // If no custom command is found, then we use one of the default ones
          if (!class_exists($command)) {
               if ($relation) {
                   $command = implode('\\', [
                      'ComdexxSolutions',
                      'Console',
                      'Commands',
                      'DefaultCommand',
                      'Relation' . ucfirst($action) . 'Command'
                   ]);
               } else {
                   $command = implode('\\', [
                       'ComdexxSolutions',
                       'Console',
                       'Commands',
                       'DefaultCommand',
                       ucfirst($action) . 'Command'
                       ]);
                     }
                   }
  
          if (!class_exists($command)) {
              throw new NotFoundHttpException('There is no default command for this action and resource.');
          }
  
          return $command;
      }
  }
  </code></pre>
  
  <p>Directory Structure:</p>
  
  <p><a href="http://laravel.io/bin/l59qa" rel="nofollow">http://laravel.io/bin/l59qa</a></p>
  
  <pre>
  vagrant@homestead:~/Code/comdexx-solutions-dcas$ tree -L 2 app
  app
  ├── ComdexxSolutions
  │   ├── Billing
  │   ├── Console
  │   ├── Contracts
  │   ├── DbCustomer.php
  │   ├── Events
  │   ├── Exceptions
  │   ├── Facades
  │   ├── Http
  │   ├── InvokeUser.php
  │   ├── Jobs
  │   ├── Listeners
  │   ├── Models
  │   ├── Providers
  │   ├── Repositories
  │   ├── Search
  │   ├── Services
  │   ├── spec
  │   ├── Traits
  │   ├── Transformers
  │   └── Views
  ├── Console
  │   ├── Commands
  │   └── Kernel.php
  ├── Entities
  ├── Events
  │   └── Event.php
  ├── Exceptions
  │   └── Handler.php
  ├── Http
  │   ├── Controllers
  │   ├── Kernel.php
  │   ├── Middleware
  │   ├── Requests
  │   └── routes.php
  ├── Jobs
  │   └── Job.php
  ├── Listeners
  ├── Modules
  ├── Providers
  │   ├── AppServiceProvider.php
  │   ├── ErrorServiceProvider.php
  │   ├── EventServiceProvider.php
  │   └── RouteServiceProvider.php
  ├── Repositories
  └── User.php
  
  33 directories, 13 files
  </pre>