I try to run my Slim framework project on XAMPP and I use Apache configuration from Slim framework website.
When I open this URL http://localhost:8081/SlimAPIProject/public/hello/ayad I get this error:
Fatal error: Uncaught Slim\Exception\HttpNotFoundException: Not found. in C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php:93 Stack trace:
#0 C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\Routing\RouteRunner.php(72): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Http\ServerRequest))
#1 C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): Slim\Routing\RouteRunner->handle(Object(Slim\Http\ServerRequest))
#2 C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\App.php(211): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest))
#3 C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\App.php(195): Slim\App->handle(Object(Slim\Http\ServerRequest))
#4 C:\xampp\htdocs\SlimAPIProject\public\index.php(16): Slim\App->run()
#5 {main} thrown in C:\xampp\htdocs\SlimAPIProject\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 93
This is my index.php
<?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('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();