.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
AllowOverride All
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();
Ошибка:
[26-Sep-2020 19:04:54 Europe/Kiev] PHP Fatal error: Uncaught RuntimeException: Could not detect any PSR-17 ResponseFactory implementations. Please install a supported implementation in order to use `AppFactory::create()`. See https://github.com/slimphp/Slim/blob/4.x/README.md for a list of supported implementations. in /home/tsecret1/API/vendor/slim/slim/Slim/Factory/AppFactory.php:167
Stack trace:
#0 /home/tsecret1/API/vendor/slim/slim/Slim/Factory/AppFactory.php(93): Slim\Factory\AppFactory::determineResponseFactory()
#1 /home/tsecret1/API/index.php(8): Slim\Factory\AppFactory::create()
#2 {main}
thrown in /home/tsecret1/API/vendor/slim/slim/Slim/Factory/AppFactory.php on line 167