title: JWT authentication in Laravel without database
body: <p>I have a question regarding Authentication in Laravel 5.x. I’ve been specifically looking at <code>tymondesigns/jwt-auth</code> and <code>irazasyed/jwt-auth-guard</code> packages to do the JSON web token authentication token handling in my Laravel application.</p>
  <p>I am not using a local database whatsoever, nor do I want to. I have environment variables set up in .env for my API’s <code>URL, USERNAME &amp; PASSWORD</code>. The Guzzle PHP HTTP client is doing the trick just fine, connecting and returning data between the API and my application as needed.</p>
  <p>However, I need to set up Authentication within my Laravel instance. I run into problems here, and the auth is wanting a DB connection.</p>
  <pre class="lang-php prettyprint-override"><code>$token = JWTAuth::attempt($credentials)
  </code></pre>
  <p>Here's the exception:</p>
  <blockquote>
  <pre><code>PDOException in Connector.php line 55: 
  SQLSTATE[HY000] [14] unable to open database file
  </code></pre>
  </blockquote>
  <ol>
  <li>How can I make use of JWT without using a database?</li>
  <li>How can I COMPLETELY shut-off database connections within Laravel?</li>
  </ol>
  <p>Thanks.</p>
  <hr />
  <p><strong>UPDATE:</strong></p>
  <p>Using <code>tymon/jwt-auth,</code> I've set things up within the routes, Kernel, Middleware, etc.</p>
  <p>I created a &quot;claim&quot; successfully, but I need to create the token by encoding the &quot;payload.&quot;</p>
  <pre class="lang-php prettyprint-override"><code>$this-&gt;username = $request-&gt;username;
  
  $sub = $this-&gt;username;
  $iat = time();
  $jti = md5($sub . $iat);
  $aud = env('APP_URL');
  
  $this-&gt;claims = [
      'sub' =&gt; $sub,
      'iat' =&gt; $iat,
      'exp' =&gt; time() + (2 * 7 * 24 * 60 * 60),
      'nbf' =&gt; $iat,
      'iss' =&gt; 'khill',
      'jti' =&gt; $jti,
      'aud' =&gt; $aud,
  ];
  
  $payload = JWTFactory::make($this-&gt;claims);
  </code></pre>
  <p>How do I get the custom token?</p>