我正在创建一个 Web 应用程序,但由于 Slim 4,我无法移动。它显示了这个错误:
Fatal error: Uncaught Slim\Exception\HttpNotFoundException: Not found. in C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php:91 Stack trace: #0 C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\Routing\RouteRunner.php(72): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): Slim\Routing\RouteRunner->handle(Object(Slim\Psr7\Request)) #2 C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\App.php(215): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #3 C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\App.php(199): Slim\App->handle(Object(Slim\Psr7\Request)) #4 C:\xampp\htdocs\projectfolder\app\index.php(16): Slim\App->run() #5 {main} thrown in C:\xampp\htdocs\projectfolder\app\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 91
我正在使用 xampp,有 apache 服务器,我认为问题存在,在.htacces
文件中,但地狱没有..
这是它的外观
我已经尝试解决这个问题超过 4-5 个小时,我尝试了我在 google、stackoverflow、Slim 的 Github、YouTube 上找到的所有内容。没有任何效果。
.htacces
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSL,L]
我的目录
作曲家.json
index.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) {
$response->getBody()->write("Hello, world!");
return $response;
});
$app->run();
我不知道该怎么办了,也许有人可以帮助我和其他成千上万找不到答案的人,或者移动并尝试另一个框架会更好。