如何在路由关闭中获取请求输入?

How do I get request input in route closure?

我刚刚读完 请求 章。我想知道如何在路由闭包中获取请求输入?

创建对象 Illuminate\Http\Request;

Route::get('/', function (Request $request) {
        $request->all();
    });

Route::get('/', function () {    
    Illuminate\Support\Facades\Input::all();
});

您可以使用全局助手:

Route::get('/', function () {
    request()->id;
});