如何在Slim PHP中使用基本身份验证?

我使用的是苗条的框架来编写自己的API,一切都很好,但是当我添加slim-basic-auth库来保护我的API并对其进行测试时…。我总是会收到此错误:

  

未捕获的错误:在中找不到类'Tuupola \ Middleware \ HttpBasicAuthentication'   D:\ xampp \ htdocs \ mydatabase \ public \ index.php:22

对此有任何帮助吗?

我安装了该库并像在教程中一样使用它

$app->add(new Tuupola\Middleware\HttpBasicAuthentication([
        "secure"=>false,"users" => [
                "username@#" => "password#@"        ]
        ]));
yddzipper 回答:如何在Slim PHP中使用基本身份验证?

您缺少反斜杠

new Tuupola\Middleware\HttpBasicAuthentication

=>

new \Tuupola\Middleware\HttpBasicAuthentication

本文链接:https://www.f2er.com/3156746.html

大家都在问