T
T
The-TS2020-09-26 21:25:49
Slim Framework
The-TS, 2020-09-26 21:25:49

Slim 4 and Error?

Code first!

.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


Hey!
Since I'm just new to Slim 4 I'm asking for your help!
How to fix this error?
I would be grateful for help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2020-09-27
@Pyhon3x

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.

They wrote to you what to do: you need to put one of these libs https://github.com/slimphp/Slim/blob/4.x/README.md... Follow
the link of any of the list and put it through the composer, for example
composer require slim/psr7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question