I’m creating an web app, and I can’t move because of Slim 4. It’s showing up this error:
Fatal error: Uncaught SlimExceptionHttpNotFoundException: Not found. in C:xampphtdocsprojectfolderappvendorslimslimSlimMiddlewareRoutingMiddleware.php:91 Stack trace: #0 C:xampphtdocsprojectfolderappvendorslimslimSlimRoutingRouteRunner.php(72): SlimMiddlewareRoutingMiddleware->performRouting(Object(SlimPsr7Request)) #1 C:xampphtdocsprojectfolderappvendorslimslimSlimMiddlewareDispatcher.php(81): SlimRoutingRouteRunner->handle(Object(SlimPsr7Request)) #2 C:xampphtdocsprojectfolderappvendorslimslimSlimApp.php(215): SlimMiddlewareDispatcher->handle(Object(SlimPsr7Request)) #3 C:xampphtdocsprojectfolderappvendorslimslimSlimApp.php(199): SlimApp->handle(Object(SlimPsr7Request)) #4 C:xampphtdocsprojectfolderappindex.php(16): SlimApp->run() #5 {main} thrown in C:xampphtdocsprojectfolderappvendorslimslimSlimMiddlewareRoutingMiddleware.php on line 91
I’m using xampp, there is apache server and I thought the problem was there, in .htacces
file, but hell no..
here is how it looks
I’ve been trying to fix this for more than 4-5 hours, I tried everything I found on google, stackoverflow, Slim’s Github, YouTube.. nothing is working.
.htacces
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSL,L]
My directory
composer.json
index.php below:
use PsrHttpMessageResponseInterface as Response;
use PsrHttpMessageServerRequestInterface as Request;
use SlimFactoryAppFactory;
require __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
$app->get('/', function (Request $request, Response $response) {
$response->getBody()->write("Hello, world!");
return $response;
});
$app->run();
I do not know what to do anymore, maybe someone can help me and other thousands of people who can’t find the answer, or it will be better idea to move and trying another framework..
2
Answers
I see some possible issues that cause the problem.
scr/
, it should besrc/
In my blog post Slim Framework Tutorial I explain this all in detail.
Set A URL base path detector for Slim 4.
Follow steps here https://github.com/selective-php/basepath
That should work properly.