title: Laravel 5.1: Class cache does not exist
body: <p>Hello dear providers of many anwsers to many questions! </p>
  
  <p>I'm using SO for a while now (5 years+), although mostly passively. This time i've got a problem which is keeping me up all night and not being able to solve it.</p>
  
  <p>Here is what it is all about. I'm using Laravel 5.1 in combination with Redis (cache &amp; session). Sadly when i switched to nginx and upgraded some packages (composer) everything stopped working. Laravel prints out the following exception:</p>
  
  <pre><code>ReflectionException in Container.php line 737:
  Class cache does not exist
  in Container.php line 737
  at ReflectionClass-&gt;__construct('cache') in Container.php line 737
  at Container-&gt;build('cache', array()) in Container.php line 627
  at Container-&gt;make('cache', array()) in Application.php line 674
  at Application-&gt;make('cache') in Container.php line 1159
  at Container-&gt;offsetGet('cache') in SessionManager.php line 156
  at SessionManager-&gt;createCacheHandler('redis') in SessionManager.php line 128
  at SessionManager-&gt;createRedisDriver() in Manager.php line 87
  at Manager-&gt;createDriver('redis') in Manager.php line 63
  at Manager-&gt;driver() in SessionServiceProvider.php line 48
  at SessionServiceProvider-&gt;Illuminate\Session\{closure}(object(Application), array()) in Container.php line 734
  at Container-&gt;build(object(Closure), array()) in Container.php line 627
  at Container-&gt;make('session.store', array()) in Application.php line 674
  at Application-&gt;make('Illuminate\Session\Store') in LittleGateKeeperServiceProvider.php line 39
  at LittleGateKeeperServiceProvider-&gt;register() in Application.php line 531
  at Application-&gt;register(object(LittleGateKeeperServiceProvider)) in ProviderRepository.php line 74
  at ProviderRepository-&gt;load(array('Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Routing\ControllerServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'App\Providers\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Lahaxearnaud\LaravelPushbullet\LaravelPushbulletServiceProvider', 'Spatie\Backup\BackupServiceProvider', 'Collective\Remote\RemoteServiceProvider', 'Vinkla\Pusher\PusherServiceProvider', 'Way\Generators\GeneratorsServiceProvider', 'Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider', 'Tymon\JWTAuth\Providers\JWTAuthServiceProvider', 'ConnorVG\Transform\TransformServiceProvider', 'Maatwebsite\Excel\ExcelServiceProvider', 'yajra\Datatables\DatatablesServiceProvider', 'Fadion\Bouncy\BouncyServiceProvider', 'Spatie\LittleGateKeeper\LittleGateKeeperServiceProvider')) in Application.php line 507
  at Application-&gt;registerConfiguredProviders() in RegisterProviders.php line 17
  at RegisterProviders-&gt;bootstrap(object(Application)) in Application.php line 203
  at Application-&gt;bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 222
  at Kernel-&gt;bootstrap() in Kernel.php line 117
  at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 87
  at Kernel-&gt;handle(object(Request)) in index.php line 54
  </code></pre>
  
  <p>Worth mentioning: I installed predis, open resty for nginx. 
  The weird thing is, if I use the file-cache-driver, it runs just fine, without any exceptions. If I ping redis through the cli i get the right 'PONG' response and i'm not sure what to do now.. (other than not using the redis driver that is ;-)).</p>
  
  <p>Maybe worth mentioning is that if i run the artisan command through the cli it gives me different errors:</p>
  
  <pre><code>PHP Catchable fatal error:  Argument 2 passed to         Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in /var/www/html/*laravel-project*/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 62 and defined in /var/www/html/*laravel-project*/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 99
  
  Catchable fatal error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in /var/www/html/*laravel-project*/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php on line 62 and defined in /var/www/html/*laravel-project*/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php on line 99
  </code></pre>
  
  <p>Therefore I've got the idea that there could be something wrong with my nginx vhost config (that was the major change to the server setup). The vhost looks like this:</p>
  
  <pre><code>server {
      listen       80 default_server;
      #listen      [::]:80 default_server ipv6only=on; ## listen for ipv6
      server_name  *MY_SERVER_NAME*;
      root         /sites/*LARAVEL_PROJECT*/public;
      charset utf-8;
  
      # Elastic search api config
      location /elastic {
          proxy_pass http://localhost:9200;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  
  
      #auth_basic_user_file /etc/nginx/htpasswd.users;
      # Kibana web access
      location /kibana {
          auth_basic "Restricted Access";
          auth_basic_user_file /etc/nginx/htpasswd.users;
          proxy_pass http://localhost:5601;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
      }
  
      # entry point to the Laravel project
      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }
  
      access_log /var/log/nginx/laravel-project-access.log;
      error_log  /var/log/nginx/laravel-project-error.log error;
  
      sendfile off;
      client_max_body_size 100m;
  
      location ~ \.php$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass unix:/var/run/php-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
          fastcgi_buffer_size 16k;
          fastcgi_buffers 4 16k;
      }
  
      location ~ /\.ht {
          deny all;
      }
  }
  </code></pre>
  
  <p>Any ideas or suggestions?</p>
  
  <p>Thx in advance!</p>