I have a problem with the operation of the website.
I installed slim framework v.4 I have php v.8.1 and the server IIS Slim 4 Documentation - Slim Framework I used this code to try if the project would start and unfortunately after many different attempts I was unable to start the website correctly.
I searched the forums but it still does not work. Has anyone encountered this problem before on the IIS server?
I believe that the cause may be this server and it will have to be configured accordingly, please advise.
I used url: http://localhost/TestSlim/index.php/
. I am trying different paths without index.php : http://localhost/TestSlim/
or http://localhost/TestSlim/index.php/hello
few times I reinstaled slim but without success. I am not sure how it works with IIS.
I used different methods I saw that problem isn’t exist for php 7.3.3 but higher like 8.1 is a problem with that
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'; //echo "test"; $app = AppFactory::create(); $app->addRoutingMiddleware(); $errorMiddleware = $app->addErrorMiddleware(true, true, true); $app->setBasePath('localhost/TestSlim'); echo $app->getBasePath(); $app->get('/', 'hello'); // Run app $app->run(); ?>
And I see the following error:
404 Not Found Type: Slim\Exception\HttpNotFoundException Code: 404 Message: Not found. File: C:\TestSlimFramework\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php Line: 91 Trace: #0 C:\TestSlimFramework\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(58): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 C:\TestSlimFramework\vendor\slim\slim\Slim\MiddlewareDispatcher.php(147): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner)) #2 C:\TestSlimFramework\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(107): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #3 C:\TestSlimFramework\vendor\slim\slim\Slim\MiddlewareDispatcher.php(147): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(Psr\Http\Server\RequestHandlerInterface@anonymous)) #4 C:\TestSlimFramework\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Psr7\Request)) #5 C:\TestSlimFramework\vendor\slim\slim\Slim\App.php(215): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #6 C:\TestSlimFramework\vendor\slim\slim\Slim\App.php(199): Slim\App->handle(Object(Slim\Psr7\Request)) #7 C:\TestSlimFramework\index.php(23): Slim\App->run() #8 {main}
I already deployed on IIS using Server->Sites->Default Web Site->Add Virtual Directory:
and added simple structure from directory