HttpNotFoundException not found

Hello, there was such an error “HttpNotFoundException not found”
brief description:

Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: …/Slim/Middleware/RoutingMiddleware.php
Line: 91

I installed the framework via composer, version 4.2
“require”: {
“slim/slim”: “4.2”,
“slim/psr7”: “^0.5”
“autoload”: {
“psr-4”: {
“App\”: “src/”

My Computer:
PHP: version 7.2.19
use apache with version 2.4.29 (default config)


use Slim\Factory\AppFactory;

require 'vendor/autoload.php';

$app = AppFactory::create();
$middleware = $app->addErrorMiddleware(true,true,true);



Just running the app doesn’t work

You haven’t got any routes set up (and if Slim is unable to find a route, the Notfound exception will be thrown). Have a look at for examples ( shows more what that file should look like).

Welcome @t.vladislav :slight_smile:

I would recomment reading the Slim 4 documentation first.
“Does’t work” needs to be explained a little bit more :wink:

Here are some things I would fix:

The file index.php should be placed in a public/ sub-directory. The public/ directory is the document root of the web server.

Create at least one route for /

$app->get('/', function (Request $request, Response $response) {
    $response->getBody()->write("Hello, world!");
    return $response;
  • Fix the namespace path in composer.json from
    "App\": "src/" to "App\\": "src"
"autoload": {
        "psr-4": {
            "App\\": "src"
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests"