# 注入一个请求对象

在Laravel中，访问用户数据的最常见工具是注入一个Illuminate\Http\Request对象实例。它可以方便的访问用户提供的数据:POST的表单数据或者JSON,GET请求(查询参数)，和URL段

> 访问请求对象的其他操作方式
>
> 有一个request()全局辅助函数和一个Request facade,他们都公开了相同的方法，这些操作公开了整个Illuminate请求对象，但是现在我只讨论用户数据相关的方法。

一旦我们注入一个请求对象，让我们看下如何获取$request对象

```php
Route::post('form', function (Illuminate\Http\Request $request) { 
    // $request->etc()
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/shou-ji-he-chu-li-yong-hu-shu-ju/zhu-ru-yi-ge-qing-qiu-dui-xiang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
