PHPackages                             dvanderburg/lumen-batched-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. [API Development](/categories/api)
4. /
5. dvanderburg/lumen-batched-request

ActiveLibrary[API Development](/categories/api)

dvanderburg/lumen-batched-request
=================================

Service provider for batched requests in Lumen framework (Laravel PHP).

251PHP

Since Nov 5Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dvanderburg/lumen-batched-request)[ Packagist](https://packagist.org/packages/dvanderburg/lumen-batched-request)[ RSS](/packages/dvanderburg-lumen-batched-request/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Lumen Batched Requests
======================

[](#lumen-batched-requests)

[![Build Status](https://camo.githubusercontent.com/486b2bce2ff107e2074be885eb2a170fa04caee57eb81a89e65df9441e90d8a4/68747470733a2f2f7472617669732d63692e6f72672f6476616e646572627572672f6c756d656e2d626174636865642d726571756573742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dvanderburg/lumen-batched-request)[![Latest Stable Version](https://camo.githubusercontent.com/38a27e62fd439f722ab5d8c3078cca78cda3a3fc415065b1d2eaaf3a10eae1c9/68747470733a2f2f706f7365722e707567782e6f72672f6476616e646572627572672f6c756d656e2d626174636865642d726571756573742f762f737461626c65)](https://packagist.org/packages/dvanderburg/lumen-batched-request)[![Total Downloads](https://camo.githubusercontent.com/61f9c79833243e91377eca7de5b754a0c21bc5b7ecb1c183c44321b6df44e732/68747470733a2f2f706f7365722e707567782e6f72672f6476616e646572627572672f6c756d656e2d626174636865642d726571756573742f646f776e6c6f616473)](https://packagist.org/packages/dvanderburg/lumen-batched-request)[![Latest Unstable Version](https://camo.githubusercontent.com/c888244d95855b83566ffce0d6c7e5fdbbf64b251405b206547df7f8ef89e7be/68747470733a2f2f706f7365722e707567782e6f72672f6476616e646572627572672f6c756d656e2d626174636865642d726571756573742f762f756e737461626c65)](https://packagist.org/packages/dvanderburg/lumen-batched-request)[![License](https://camo.githubusercontent.com/1cf57acf0ab99348702dd5b794e78bf49134093257395b12a1220a5e503f85f8/68747470733a2f2f706f7365722e707567782e6f72672f6476616e646572627572672f6c756d656e2d626174636865642d726571756573742f6c6963656e7365)](https://packagist.org/packages/dvanderburg/lumen-batched-request)

Lumen service provider to perform batched requests. Usage and implementation roughly based on [making batch requests](https://developers.facebook.com/docs/graph-api/making-multiple-requests) with Facebook's Graph API.

Batching requests allows you to send multiple requests at once, allowing you to perform multiple operations in a single HTTP request. Each request in the batch is processed in sequence unless dependencies are specified.

Requests within the batch can list dependancies on other requests within the batch, and access their responses via JSONP syntax. Again, similar to Facebook's Graph API. Using [JSONP syntax](https://code.google.com/archive/p/jsonpath/), a request in the batch can use the response from another request in the batch. More information is provided in the [Usage and Examples](#Usage-and-Examples) section.

Once all requests have been completed, an array of responses will be returned and the HTTP connection closed.

Built on PHP 7.1.13 and Laravel Framework Lumen (5.6.3).

Dependancies
------------

[](#dependancies)

- **PHP &gt;=7.1** Built and tested on PHP 7.1.13
- **Laravel/Lumen ~5.6** Originally built using Laravel Lumen version 5.6.3 ()
- **FlowCommunications/JSONPath ~0.4.0** Accommodates JSONP parsing for specifying dependancies ()

Installation and Setup
----------------------

[](#installation-and-setup)

Install the package via [composer](https://getcomposer.org/).

```
composer install dvanderburg/lumen-batched-request
```

Register the service provider in app.php

```
$app->register(Dvanderburg\BatchedRequest\BatchedRequestServiceProvider::class);
```

Simple Batched Requests
-----------------------

[](#simple-batched-requests)

Send a basic batched request by sending an HTTP post to `/batch/`. This example will perform two GET requests and a POST, returning an array of responses.

HTTP POST Example:

```
POST /batch HTTP/1.1
Content-Type: application/json
batch: [
	{ method: "GET",	relative_url: "/product/1234" },
	{ method: "GET",	relative_url: "/user/?ids=larry,jill,sally" },
	{ method: "POST",	'content-type': "application/x-www-form-urlencoded", name: 'create-user', relative_url: "/user/?username=john" body: "password=admin"},

```

[Axios](https://github.com/axios/axios) XHR Example:

```
axios.post('/batch', {
	batch: [
		{ method: "GET",	relative_url: "/product/1234" },
		{ method: "GET",	relative_url: "/user/?ids=larry,jill,sally" },
		{ method: "POST",	'content-type': "application/x-www-form-urlencoded", name: 'create-user', relative_url: "/user/?username=john" body: "password=admin"},
	]
});
```

[JQuery](https://github.com/jquery/jquery) XHR Example:

```
$.ajax({
	method: "POST",
	dataType: "json",
	data: {
		batch: [
			{ method: "GET",	relative_url: "/product/1234" },
			{ method: "GET",	relative_url: "/users/?ids=larry,jill,sally" },
			{ method: "POST",	'content-type': "application/x-www-form-urlencoded", name: 'create-user', relative_url: "/user/?username=john" body: "password=admin" },
		]
	}
})
```

For the examples above, the expected response format would be:

```
[
	{
		code: 200,
		body: { product_id: 1234 }
	},
	{
		code: 200,
		body: [{ username: "larry" }, { username: "jill" }, { username: "sally" }]
	},
	{
		code: 200,
		body: { username: "john" }
	},
]
```

Errors
------

[](#errors)

If a specific request in the batch fails, its response within the array of responses will contain a non-200 code. However, the actual HTTP request to process the batch will still return a 200-OK.

Specifying Dependencies with JSONP
----------------------------------

[](#specifying-dependencies-with-jsonp)

Sometimes the operation of one request in the batch is dependant on the response of another. This dependancy can be created by specifying a name for a request and then accessing the response of that request using JSONP syntax.

The following example retrieves a user's collection of books which are represented with a `book_id`. The book IDs are then used by a second request in the batch to retrieve information about those books.

HTTP POST Example:

```
POST /batch HTTP/1.1
Content-Type: application/json
batch: [
	{ "method": "GET", "name": "get-user-books", "relative_url": "/user_books/?username=larry" },
	{ "method": "GET", "relative_url": "/book/?book_ids={result=get-user-books:$.book_id}" },

```

In the example above, the first request in the batch is named get-user-books and the second request references that request by name and uses JSONP syntax to extract all the book\_ids from the first request in order to know what books to retrieve.

The result of the JSONP expression is exported in csv format. In the example above that may look like: `1234,5678,9012`.

If a request is a dependancy of another request and fails, it will cause the request which is dependant on it to also fail. In the above example if the get-user-books request fails, the request to retrieve books will also fail.

Headers, Cookies, and Files
---------------------------

[](#headers-cookies-and-files)

Headers, cookies, and files associated with the HTTP request to `/batch/` will be available to all requests in the batch. For example: Sending bearer-token authentication as a header will set that header on all subrequests in the batch, meaning any authenticaiton middleware will be executed for each request in the batch.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![dvanderburg](https://avatars.githubusercontent.com/u/1413980?v=4)](https://github.com/dvanderburg "dvanderburg (17 commits)")

---

Tags

batch-requestjsonplaravellumenphprest-api

### Embed Badge

![Health badge](/badges/dvanderburg-lumen-batched-request/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M478](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M271](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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