Auto import imports different classes

The initial example show in the documentation (and home page) shows the following use classes:

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

But when i enter the code and auto import the classes it imports a different set of classes as follows:

use Slim\Psr7\Request;
use Slim\Psr7\Response;
use Slim\Factory\AppFactory;

When I test the app with these classes, it crashes.

Appreciate any help.

What classes/interfaces are you using on the controller method(s)?

     * @param \Psr\Http\Message\ServerRequestInterface $request
     * @param \Psr\Http\Message\ResponseInterface $response
     * @param array $args
     * @return \Psr\Http\Message\ResponseInterface
     public function index(Request $request, Response $response, $args): Response {

You may try to use the Interfaces instead. So just remove the alias:

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

Example route:

$app->get('/example', function (ServerRequestInterface $request, ResponseInterface $response) {
    return $response;

This is your own example code in your documentation after i use the auto-import in vs code ide:


use Slim\Psr7\Request;
use Slim\Psr7\Response;
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;


This is the composer.json:

    "require": {
        "slim/slim": "4.*",
        "slim/psr7": "^1.6",
        "slim/http": "^1.3",
        "php-di/php-di": "^7.0",
        "mustache/mustache": "^2.14"
    "require-dev": {
        "kint-php/kint": "^5.0"

I am a newbie to this framework. This is all i can provide and there is nothing in your documentation that explains this.

I would recommend taking a look at my Slim 4 Tutorial which shows and explains how to set up a Slim project from scratch.