Problems with starting code

I am starting to use Slim, step by step installing slim and Psr7 and copying the initial demo code and I always get 500 error.
I also create the .htaccess file in the same folder ( the main folder) as index.php. I don’t understand what’s happening because I’m following the guide.
I’m using Linux and Xamp, php 8.1, slim 4.10. I also have probe it in windows with Wamp server with identical result.

Can anyone get me some light about this?:wink:

Can you show us more error details?

When I start my app on the server in Windows Wamp I get this result…

Fatal error: Uncaught Slim\Exception\HttpNotFoundException: Not found. in C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php:76 Stack trace: #0 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Routing\RouteRunner.php(56): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\MiddlewareDispatcher.php(65): Slim\Routing\RouteRunner->handle(Object(Slim\Psr7\Request)) #2 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\App.php(199): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #3 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\App.php(183): Slim\App->handle(Object(Slim\Psr7\Request)) #4 C:\xampp\htdocs\phpslim\public\index.php(15): Slim\App->run() #5 {main} thrown in C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 76

In linux Lamp I receive this–>

Esta página no funciona

La página localhost no puede procesar esta solicitud ahora.


My /public/.htaccess code

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

my .htaccess code

RewriteEngine On
RewriteBase /phpslim

RewriteCond %{THE_REQUEST} /public/([^\s?]) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^(.
)$ public/index.php?$1 [L,QSA]

and my /public/index.php code

<?php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require __DIR__ . '/../vendor/autoload.php'; $app = AppFactory::create(); $app->get('/', function (Request $request, Response $response, $args) { $response->getBody()->write("Hello world!"); return $response; }); $app->run(); All of this code is extracted of the guide. Thanks for your help.

Must be something about the Apache server because if I use this sentence


it works, but in the official documentation indicates this as a other way to configurate the app. Well, thanks for all.

The regex looks not correct to me and the basePath must be set.

Can you try this solution here?