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

witxhnet's avatar

request() helper vs Request $request?

I'm watching the Laravel 5.7 From Scratch series, and for handling requests in some way, I mostly see request() used.

The Laravel documentation seems to mostly type hint Request $request into whatever method is called, like this:

public function update(Request $request, $id)
{
     $request->all();
}

To me, it seems convenient to just use request() instead since you don't need to pass it as a parameter, so something like:

public function update($id)
{
     request()->all();
}

It seems like it does the exact same thing looking at the docs. Is that true? Is there a difference that I'm not aware of? Is it better to use one over the other?

Here is the request() helper method I'm talking about: https://laravel.com/docs/5.7/helpers#method-request

Thanks :)

0 likes
2 replies
Sergiu17's avatar
Sergiu17
Best Answer
Level 60

Hi, there's no difference between them, they do exactly the same thing.

request() - is a helper function ( wrapper function ) , open vendor/laravel/framework/src/Illuminate/Foundation/helpers.php - to see others

2 likes
witxhnet's avatar

That's great to know. Thank you so much dude :) I think I'll just use request() for the most part then.

Please or to participate in this conversation.