title: How to use Memcached for session in Laravel 5.7?
body: <p>Normally I used file as driver to store session and cache. Now I want to work with <code>Memcached</code> to store session and cache on Laravel 5.7 application. It is new to me. I have already installed <code>php-memcached</code> on my local environment.</p>
  
  <p>In my Laravel 5.7 web application I have configured <code>session.driver</code> and <code>cache.default</code> in the <code>.env</code> file as following.</p>
  
  <pre><code>SESSION_DRIVER=memcached
  CACHE_DRIVER=memcached
  </code></pre>
  
  <p>I leave everything else with its default installation. When I refresh the page I get the following error.</p>
  
  <pre><code>Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
  Class 'Memcached' not found
  /vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php 69
  </code></pre>
  
  <p>I do understand that when you configure driver for session and cache config to use <code>Memcached</code>, the <code>MemcachedConnector</code> will get involved. It imports the <code>Memcached</code> class and tries to create an instance object of the <code>Memcached</code> class as following.</p>
  
  <pre><code>use Memcached;
  
  class MemcachedConnector {
      protected function createMemcachedInstance($connectionId) {
          return empty($connectionId) ? new Memcached : new Memcached($connectionId);
      }
  }
  </code></pre>
  
  <p>With the above error, it seems like the <code>Memcached</code> class is missing. How can I solve it? Please do not tell me to do the following even it solves the problem.</p>
  
  <pre><code>SESSION_DRIVER=file
  CACHE_DRIVER=file
  </code></pre>
  
  <p>or </p>
  
  <pre><code>SESSION_DRIVER=array
  CACHE_DRIVER=array
  </code></pre>
  
  <p>Because I would like to use <code>Memcached</code> and would like to know what to do to make it work.</p>