title: Access app in class in Slim Framework 3
body: <p>Im having trouble understanding how to access the instance of Slim when a route is in a seperate class than index.php</p>
  
  <p>When using Slim Framework 2 I always used the following, but its not working in Slim 3:</p>
  
  <pre><code>$this-&gt;app = \Slim\Slim::getInstance();
  </code></pre>
  
  <p>Im trying to access a database connection I have setup in the container, but from a separate class. This is what I currently got in my index.php to initiate a Slim app:</p>
  
  <pre><code>require_once("rdb/rdb.php");
  $conn = r\connect('localhost');
  $container = new \Slim\Container;
  $container['rdb'] = function ($c){return $conn;}
  $app = new \Slim\App($container);
  </code></pre>
  
  <p>And here is my route:</p>
  
  <pre><code>$app-&gt;get('/test','\mycontroller:test');
  </code></pre>
  
  <p>And this is what I got in my mycontroller.php class which my route points to, which obviously is not working as $this->app doesn't exist: </p>
  
  <pre><code>class mycontroller{
  public function test($request,$response){
  $this-&gt;app-&gt;getContainer()-&gt;get('rdb');
  }
  </code></pre>
  
  <p>The error message is the following, due to getinstance not being part of Slim 3 compared to Slim 2:</p>
  
  <pre><code>Call to undefined method Slim\App::getInstance() 
  </code></pre>
  
  <p>Grateful for any help,</p>
  
  <p>Regards
  Dan</p>