PHPackages                             xaboy/laravel-merge-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. xaboy/laravel-merge-request

ActiveLibrary

xaboy/laravel-merge-request
===========================

laravel框架 根据路由规则创建/发起虚拟请求,可以在当前请求中发起多个虚拟请求

v1.0.0(7y ago)08MITPHPPHP &gt;=7.0

Since Feb 19Pushed 7y agoCompare

[ Source](https://github.com/xaboy/laravel-merge-request)[ Packagist](https://packagist.org/packages/xaboy/laravel-merge-request)[ Docs](https://github.com/xaboy/laravel-merge-request)[ RSS](/packages/xaboy-laravel-merge-request/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

LaravelMergeRequest
===================

[](#laravelmergerequest)

laravel框架 根据路由规则创建/发起虚拟请求,可以在当前请求中发起多个虚拟请求

安装
--

[](#安装)

`composer require xaboy/laravel-merge-request`

说明
--

[](#说明)

### 示例

[](#示例)

路由规则

```
//获取验证码
Route::get('captcha', 'AuthController@captcha');

//登录并返回用户id
//例: [user_id=>1]
Route::post('login','AuthController@login');

//根据用户id获取用户信息
Route::get('user/info/{id}','AuthController@userInfo');
```

合并上面三条路由规则

```
use Xaboy\MergeRequest\MergeRequest;

$mergeRequest = new MergeRequest([
    'loginInfo'=>'auth/loginInfo',
    'login'=>[
        'path'=>'login',
        'method'=>'post',
        'post'=>[
            'username'=>'username',
            'password'=>'password',
        ]

    ],
    'userInfo'=>[
        'path'=>'user/info/{id}',
        'route'=>[
            'id'=>'${mr:login.user_id}' //模板变量
        ]
    ]
])
```

发起虚拟请求

```
$mergeData = $mergeRequest->run();
```

### 规则

[](#规则)

- `path` : 路由规则/请求地址/路由别名/控制器@方法
- `method` : 请求方式,默认为`GET`
- `route` : 路由参数
- `post` : POST 参数,默认为当前请求的 POST 参数
- `get` : GET 参数,默认为当前请求的 GET 参数
- `files` : FILE 参数,默认为当前请求的 FILE 参数
- `parameter` : 自定义参数,默认为当前请求的自定义参数

以上配置项都支持模板变量

### 事件

[](#事件)

- `executing` : 发起模拟请求时触发

    参数:

    - `$key`: 生成规则的 key
    - `&$mergeData` : 该请求之前已请求到的数据
- `executed` : 发起模拟请求之后触发

    参数:

    - `$res` : 该请求返回的数据
    - `$key`: 生成规则的 key
    - `&$mergeData` : 该请求之前已请求到的数据
- `loaded` : 所有模拟请求结束后触发

    参数:

    - `&$mergeData` : 所有模拟请求返回的数据

示例

```
class Observer{
    public function executing($key, $mergeData){}
    public function executed($res, $key, $mergeData){}
    public function loaded($mergeData){}
}

//绑定
$mergeRequest->observer(Observer::class);
```

### 模板变量

[](#模板变量)

`${mr:key.res.data}`

参考上面的示例

更多示例
----

[](#更多示例)

路由规则

```
Route::post('user/update/{id}','AuthController@updateUser')->name('user.update');
```

规则1

```
[
    'path'=>'user/update/{id}',
    'method'=>'post',
    'route'=>[
        'id'=>1
    ]
]
```

规则2

```
[
    'path'=>'AuthController@updateUser',
    'method'=>'post',
    'route'=>[
        'id'=>1
    ]
]
```

规则3

```
[
    'path'=>'user.update',
    'method'=>'post',
    'route'=>[
        'id'=>1
    ]
]
```

规则4

```
[
    'path'=>'user/update/1',
    'method'=>'post'
]
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2640d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfc1dbf8cebcd0dc870cbaa6bb0ac7d20499acff2fe8fea03424ca407efaee61?d=identicon)[xaboy](/maintainers/xaboy)

---

Top Contributors

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

---

Tags

requestlaravel

### Embed Badge

![Health badge](/badges/xaboy-laravel-merge-request/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[lionix/castable-request

Laravel castable requests

2392.2k](/packages/lionix-castable-request)[mnabialek/laravel-eloquent-filter

Allows filtering Eloquent queries by input filters

2614.5k](/packages/mnabialek-laravel-eloquent-filter)[behamin/service-proxy

for proxy or sending requests to other services with useful utilities

102.2k](/packages/behamin-service-proxy)

PHPackages © 2026

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