Fail hello world windows 11 xampp 8.2 Slim 4.11.0 - June 2024

{
“require”: {
“slim/slim”: “4.*”,
“nyholm/psr7”: “^1.8”,
“nyholm/psr7-server”: “^1.1”
}
}

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

This looks like an expected exception if Slim’s routing cannot find the requested page.

Look at your app and compare it with the example on https://www.slimframework.com, or the code in a skeleton like GitHub - akrabat/slim4-empty: Minimal Slim 4 starter project

I´m just using the sample like documentation, without modifications…

<?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();

I found a solution; i put the full route:

$app->get(‘/api/’, function (Request $request, Response $response, $args) {
$response->getBody()->write(“Hello world!”);
return $response;
});

and the “hello words” appears;

thanks.

1 Like