laravel - use Request class or input class

2019-04-28 22:20发布

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?

3条回答
戒情不戒烟
2楼-- · 2019-04-28 22:49

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

查看更多
Summer. ? 凉城
3楼-- · 2019-04-28 22:49

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

查看更多
三岁会撩人
4楼-- · 2019-04-28 23:03

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/

查看更多
登录 后发表回答