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:
<?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->run();
?>
and this file books.php which is my page:
<?php
$app->get('/api/books', function() {
echo "Welcome to books";
});
?>
This is my folder structure:
I run this on localhost with wamp using this link:
localhost:8082/myslimsite/app/api/books
I got my localhost on port 8082, my php version is 7.0.10
This are my errors
I try to find on the internet solution but nothing works, something that I found and tried was:
1 - For books to use ($app) like this:
<?php
$app->get('/api/books', function() {
echo "Welcome to books";
});
?>
2 - In books to use the file with the class that have $app variable
require '../vendor/autoload.php';
$app = new \Slim\App;