I've tried so many settings. Here we go...
The root of my project is in blog/
Inside the blog I have the public/ folder and inside it the Slim4 index.php and a flarum/ folder
Whenever I try to create a route, I get an error because the file could not be found or a boot error.
At this point I came to this code
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
// Middleware to forward requests to Flarum
$app->add(function (Request $request, $handler) {
ob_start();
// Path to Flarum's index.php
$flarumIndex = __DIR__ . '/../flarum/public/index.php';
// Check if the file exists
if (file_exists($flarumIndex)) {
// Change the working directory to Flarum's directory
chdir(__DIR__ . '/../flarum/public');
// Include Flarum's index.php
include $flarumIndex;
} else {
// File not found, return 404 error
return (new \Slim\Psr7\Response())->withStatus(404);
}
// Capture the output
$output = ob_get_clean();
// Create the response
$response = new \Slim\Psr7\Response();
$response->getBody()->write($output);
return $response;
});