0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

My word. I feel like a right prat now. Thank you Sven. When I used the alias I copied it from the other file I had open, then :u to undo, hence why it worked, then failed when I removed. ha ha. /facepalm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.