laravel - use Request class or input class

2019-04-28 22:48发布

问题:

In a restful controller, which class should I use to get passed variables?

$member->email = Input::get('email');
// or
$member->email = Request::get('email');

both options work for me, but whats the difference?

回答1:

Input::get() is just a helper that maps to the Request class. It doesn't really matter which you use.



回答2:

I believe that Request is preferred in the context of a restful controller.



回答3:

With Laravel 3 i prefer to use:

$member->email = Input::get('email');

But with Laravel 4 I prefer to use:

$member->email = Request::get('email');

Please check the article:

http://net.tutsplus.com/tutorials/php/laravel-4-a-start-at-a-restful-api/