Reputation: 8938
I'm having an issue with my code below. The error I get is:
Catchable fatal error: Argument 1 passed to Closure::QuizApp\Routes{closure}() must be an instance of QuizApp\Routes\ServerRequestInterface, instance of Slim\Http\Request given in /var/www/QuizApp/Routes/AuthRoutes.php on line 8
Is this because I'm declaring a namespace at the top? I can solve it by using an alias, but I'm curious as to why it's happening in the first place.
<?php
namespace QuizApp\Routes;
use \Psr\Http\Message\ServiceRequestInterface;
use \Psr\Http\Message\ResponseInterface;
$app->get('/login', function(ServerRequestInterface $req, ResponseInterface $resp) use ($config) {
$callback = $config['site']['domain'] . $this->router->pathFor('fb_callback');
return $this->FBAuthServices->redirect_to_auth_page($config['facebook']['permission'],
$callback);
});
Edit After looking at my own code, I realize I don't even need the namespace. The class that was in this file, has now been moved out. Would still love an answer though, I'm curious.
Upvotes: 0
Views: 1438
Reputation: 70863
Compare these
must be an instance of QuizApp\Routes\ServerRequestInterface
use \Psr\Http\Message\ServiceRequestInterface;
It's a typo, it should be named ServerRequestInterface
in the use
.
Upvotes: 1