PHPackages                             goenitz/request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. goenitz/request

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

goenitz/request
===============

A class to get request variables.

v1.1.0(9y ago)153MITPHPPHP &gt;5.3

Since Mar 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tianyirenjian/request)[ Packagist](https://packagist.org/packages/goenitz/request)[ RSS](/packages/goenitz-request/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Request
=======

[](#request)

#### 安装方式

[](#安装方式)

```
composer require goenitz/request
```

在我们获取 get 或者 post 参数的时候是这样的

```
$email = isset($_POST['email']) ? $_POST['email'] : '';
$email = trim($email);
if ($email == '') {
    //do sth
}
```

现在你可以这样使用

```
$request = new \Goenitz\Request\Request();

$email = $request->post->email;
if (is_null($email)) {
    //do sth
}

//or
$email = $request->post['email'];

//or
$email = $request->post('email');

//or set a default value
$email = $request->post('email', 'xxx@xxx.com');

//or get all post data as an array.
$post = $request->post->toArray();
```

支持 get, post, request, server, cookie, session 数据的获取。

```
$page = $request->get->page;
$ip = $request->server->REMOTE_ADDR
// etc.
```

//单独的 ip 方法

```
$ip = $request->ip();
```

从 v1.0.0 版本开始支持 $\_FILES

```
$files = $request->files->toArray();

$file = $request->files->file;
//or
$file = $request->files('file');
//or
$file = $request->files['file'];

$file->getOriginalFileName();  // "32fa828ba61ea8d33395a581970a304e241f5884.gif"
$file->getOriginalExtension(); // "gif"
$file->getTempName();          // "C:\Users\tianyi\AppData\Local\Temp\php363C.tmp"
$file->getType();              // "image/gif"
$file->getError();             // 0
$file->save('./1.gif');        // true
```

#### 说明

[](#说明)

默认会对参数运行 trim 方法，如果为空字符串，则会转换为 null。 你可以给构造函数传递参数来阻止这种行为。

```
$request = new \Goenitz\Request\Request(false, false);
```

#### change logs

[](#change-logs)

##### v1.0.0 =&gt; v1.1.0

[](#v100--v110)

- 添加 ip方法获取ip
- 修改目录结构

##### 0.20 =&gt; v1.0.0

[](#020--v100)

- 添加 $\_FILES 支持

##### 0.10

[](#010)

- 添加 `$request->post["key"]` 获取方式
- `ArrayObject` 类添加 `toArray` 方法， 现在可以通过 `$post = $request->post->toArray();` 直接获取整个 post 的数据
- `Request` 类添加一些注释，便于 IDE 进行代码提示

##### 0.01

[](#001)

- 初始功能

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Total

2

Last Release

3318d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01b8c119a491e1583e732fef4d8bfea2b36398d8081895b78987ab2248588868?d=identicon)[Goenitz](/maintainers/Goenitz)

---

Top Contributors

[![tianyirenjian](https://avatars.githubusercontent.com/u/3616700?v=4)](https://github.com/tianyirenjian "tianyirenjian (8 commits)")

---

Tags

request

### Embed Badge

![Health badge](/badges/goenitz-request/health.svg)

```
[![Health](https://phpackages.com/badges/goenitz-request/health.svg)](https://phpackages.com/packages/goenitz-request)
```

###  Alternatives

[lionix/castable-request

Laravel castable requests

2393.0k](/packages/lionix-castable-request)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
