title: Laravel 5 - Class 'DB' not found
body: <p>I have <code>ChatController</code> located in <code>app/http/controllers</code> like so:</p>
  
  <p>
  
  <pre><code>namespace App\Http\Controllers;
  
  use App\Http\Controllers\Controller;
  
  use Ratchet\MessageComponentInterface;
  use Ratchet\ConnectionInterface;
  use DB;
  
  class ChatController extends Controller implements MessageComponentInterface {
  
      protected $clients;
  
      function __construct() {
          $this-&gt;clients = new \SplObjectStorage;
      }
  
      public function onOpen(ConnectionInterface $conn) 
      {
          $this-&gt;clients-&gt;attach($conn);
      }
  
      public function onMessage(ConnectionInterface $conn, $msg) 
      {
          foreach ($this-&gt;clients as $client) 
          {
              if ($client !== $conn )
                  $client-&gt;send($msg); 
  
              DB::table('messages')-&gt;insert(
                  ['message' =&gt; $msg]
              );
          }
      }
  
      public function onClose(ConnectionInterface $conn) 
      {
          $this-&gt;clients-&gt;detach($conn);
      }
  
      public function onError(ConnectionInterface $conn, \Exception $e) 
      {
          echo 'the following error occured: ' . $e-&gt;getMessage();
          $conn-&gt;close();
      }
  
  }
  </code></pre>
  
  <p>And I have <code>chatserver.php</code> file in the root like so:</p>
  
  <pre><code>&lt;?php
  require  'vendor/autoload.php';
  
  use Ratchet\Server\IoServer;
  use Ratchet\Http\HttpServer;
  use Ratchet\WebSocket\WsServer;
  use App\Http\Controllers\ChatController;
  
  
  $server = IoServer::factory(
      new HttpServer(
          new WsServer(
              new ChatController()
          )
      ),
      8080
  );
  
  $server-&gt;run();
  </code></pre>
  
  <p>If I remove </p>
  
  <pre><code>DB::table('messages')-&gt;insert(
                      ['message' =&gt; $msg]
                  );
  </code></pre>
  
  <p>from the <code>ChatController</code> and start <code>chatserver.php</code> it works, but if I don't remove it then the server starts but as soon as I send a message I get this error:</p>
  
  <pre><code>Fatal error: Uncaught Error: Class 'DB' not found in C:\wamp\www\laraveltesting\app\Http\Controllers\ChatController.php:31
  </code></pre>
  
  <p>Why won't it use DB? I am extending the laravel controller.</p>