title: Routing in SlimFramework
body: <p>I follow a tutorial for SlimFramwork and I try to route through some pages that I defined. I have this index.php file from which I run:</p>
  
  <pre><code>&lt;?php
  use \Psr\Http\Message\ServerRequestInterface as Request;
  use \Psr\Http\Message\ResponseInterface as Response;
  
  require '../vendor/autoload.php';
  
  $app = new \Slim\App;
  
  require_once('../app/api/books.php');
  
  $app-&gt;run();
  
  ?&gt;
  </code></pre>
  
  <p>and this file books.php which is my page:</p>
  
  <pre><code>&lt;?php
  
  $app-&gt;get('/api/books', function()  {
      echo "Welcome to books";
  });
  
  ?&gt;
  </code></pre>
  
  <p>This is my folder structure:</p>
  
  <p><img src="https://i.stack.imgur.com/Iv4CB.jpg" alt="Folder structure"></p>
  
  <p>I run this on localhost with wamp using this link: </p>
  
  <p>localhost:8082/myslimsite/app/api/books  </p>
  
  <p>I got my localhost on port 8082, my php version is 7.0.10</p>
  
  <p>This are my errors</p>
  
  <p><img src="https://i.stack.imgur.com/O3V6l.jpg" alt="Errors"></p>
  
  <p>I try to find on the internet solution but nothing works, something that I found and tried was:</p>
  
  <p>1 - For books to use ($app) like this:</p>
  
  <pre><code>&lt;?php
  
  $app-&gt;get('/api/books', function()  {
      echo "Welcome to books";
  });
  
  ?&gt;
  </code></pre>
  
  <p>2 - In books to use the file with the class that have $app variable  </p>
  
  <pre><code>require '../vendor/autoload.php';
  $app = new \Slim\App;
  </code></pre>