Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

onurzdgn's avatar

: RedirectResponse

Hi everyone I am using laravel 10. I am curious something. What is : RedirectResponse?

0 likes
4 replies
Snapey's avatar

It's the return type of the method. Are you seeing this in a controller?

onurzdgn's avatar

@Snapey Yes I am seeing in controller. For example:

 public function logout(Request $request): RedirectResponse
    {
        Auth::logout();
        $request->session()->invalidate();
        $request->session()->regenerateToken();
 
        return redirect('login');
    }
Snapey's avatar
Snapey
Best Answer
Level 122

@onurzdgn The redirect function returns a RedirectResponse object, which you then return from the controller, satisfying the return type.

In other cases, you might want to return a view, in which case the return type will need to be different.

Please or to participate in this conversation.