I am having some issues setting up routes in my app in different directories. The app only loads one of the routes files.
File Structure
myapp
|_public
| |_vendor
| |_index.php
|_src
|_routes
|_books.php
|_customers.php
index.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require './vendor/autoload.php';
$app = new \Slim\App;
// Routes
require '../src/routes/books.php';
require '../src/routes/customers.php';
$app->run();
customers.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
$app = new \Slim\App;
$app->get('/api/customers', function(Request $request, Response $response){
echo 'Customers';
});
books.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
$app = new \Slim\App;
$app->get('/api/books', function(Request $request, Response $response){
echo 'Books';
});
So with the above structure, only one on the routes file is loaded depending on the order in the file structure. Either the book routes or the customer routes and the order will return a Page not Found Error.
I don't understand.T