自动加载:Class 在不删除 require 语句的情况下未找到

Autoload: Class not found without removing require statements

问题:我想从我的代码中删除 require 语句并改用自动加载。但是当我这样做时,我有一个 class not found error:

结构:

composer.json
index.php
users/user-model.php
users/users-route.php

作曲家Json(我运行作曲家转储自动加载):

....  
"autoload": {
    "psr-4": {
      "User\": "users/"
    }

Index.php:

require_once __DIR__ . '/vendor/autoload.php';

//require ('users/user-model.php'); HERE: Doesn't work when I comment this

$klein = new \Klein\Klein();

require ('users/users-routes.php');

$klein->dispatch();

用户-route.php:

use User\UserModel as user;

$klein->respond( 'GET', '/', function( $request, $response, $service, $app ) {
    $tt = new user();
    echo $tt::name();
} );

用户-model.php:

namespace User;

class UserModel
{

    public static function name()
    {
        return 'bob';
    }
}

我应该改变什么,这样我就不需要了:require ('users/user-model.php'); ?

如果您想使用自动加载,请按照声明的方式执行 in accordance with psr-4

The file name MUST match the case of the terminating class name.

将文件重命名为 UserModel.php