title: Using PHP Slim Framework inside of Classes
body: <p>I can't seem to get the Slim framework to access functions inside the scope of a PHP class:</p>
  
  <pre><code>&lt;?php
  
  class Controller {
      private $app;
  
      public function __construct() {
          $this-&gt;app = new Slim();
  
          $this-&gt;app-&gt;get('/', $this-&gt;home);
  
          $this-&gt;app-&gt;run();
      }
  
      public function home() {
          echo 'hi';
      }
  }
  </code></pre>
  
  <p>This causes the following error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'ErrorException' with message
    'Undefined property: Controller::$home' in
    /Users/Oliver/Dropbox/Sites/grapevine/application/controller.php:9
    Stack trace: #0
    /Users/Oliver/Dropbox/Sites/grapevine/application/controller.php(9):
    Slim::handleErrors(8, 'Undefined prope...', '/Users/Oliver/D...', 9,
    Array) #1 /Users/Oliver/Dropbox/Sites/grapevine/public/index.php(14):
    Controller->__construct() #2 {main} thrown in
    /Users/Oliver/Dropbox/Sites/grapevine/application/controller.php on
    line 9</p>
  </blockquote>
  
  <p>I have tried doing this instead:</p>
  
  <pre><code>$this-&gt;app-&gt;get('/', $this-&gt;home());
  </code></pre>
  
  <p>But then the routing is ignored, and 'hi' is displayed on every page, not just '/'.</p>