DEV Community

N3no
N3no

Posted on

Slim REST API

I want to handle multiple require's in my index.php, but only the last one is considered.

`<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Selective\BasePath\BasePathMiddleware;
use Slim\Factory\AppFactory;

require DIR . '/../vendor/autoload.php';
require DIR . '/../config/db.php';

$app = AppFactory::create();
$app->setBasePath('/Slim/HRS-API/public');

$routeFiles = [
'rooms.php',
'extra.php',
'hotel.php',
'price.php',
];

require DIR . '/../routes/berechtigung.php';*/
foreach ($routeFiles as $routeFile) {
require DIR . '/../routes/' . $routeFile;
}

$app->run();`

So only the last API-Endpoint is available (http://localhost/Slim/my-route/public/price) and all the others are not.

Does someone now what the problem could be?

Thank you

Top comments (0)