tuupola/slim-basic-auth

Argument 1 passed to Slim\Slim::add() must be an instance of Slim\Middleware

Closed this issue · 1 comments

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim(array(
    'debug' => true
));

$app->add(new \Slim\Middleware\HttpBasicAuthentication([
     "secure" => false,
     "users" => [
         "root" => "root",
     ]
]));

Catchable fatal error: Argument 1 passed to Slim\Slim::add() must be an instance of Slim\Middleware, instance of Slim\Middleware\HttpBasicAuthentication given, called in /home/c19193/public_html/index.php on line 18 and defined in /home/c19193/public_html/lib/Slim/Slim.php on line 1267

What is wrong with my configuration?

Slim 2, Slim\Middleware\HttpBasicAuthentication for Slim 2

Slim 2 is only supported by 1.x branch. 2.x and 3.x branches are for Slim 3.

$ composer require tuupola/slim-basic-auth:^1.0