aef/laravel-batch-requests
| Install | |
|---|---|
composer require aef/laravel-batch-requests |
|
| Latest Version: | v1.1.0 |
| PHP: | ^8.2 |
| Laravel: | 10 · 11 · 12 |
| Older releases: | 8 · 9 |
| License: | MIT |
| Last Updated: | Aug 19, 2025 |
| Links: | GitHub · Packagist |
Laravel Batch Requests
A Laravel package for efficiently handling multiple API requests in a single batch operation, reducing network overhead and improving performance for bulk operations.
Installation
You can install the package via composer:
composer require aef/laravel-batch-requests
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="LaravelBatchRequests\BatchRequestServiceProvider" --tag="config"
This will create a config/batch-requests.php file where you can modify the package settings.
Usage
use LaravelBatchRequests\Http\Controllers\BatchRequestController;
Route::post('batch', [BatchRequestController::class, 'process']);
To use the batch request functionality, send a POST request to the /api/batch endpoint with a JSON payload containing
an array of requests:
{
"requests": [
{
"id": "get-user",
"method": "GET",
"uri": "/api/users/1",
"headers": {
"Accept": "application/json"
}
},
{
"id": "create-post",
"method": "POST",
"uri": "/api/posts",
"parameters": {
"title": "New Post",
"content": "This is the content of the new post."
},
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
}
}
]
}
The response will contain the results of all the batched requests, with the body returned as parsed JSON:
{
"results": [
{
"id": "get-user",
"status": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"id": 1,
"name": "John Doe"
}
},
{
"id": "create-post",
"status": 201,
"headers": {
"Content-Type": "application/json"
},
"body": {
"id": 101,
"title": "New Post",
"content": "This is the content of the new post."
}
}
]
}
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.1.0 | ^8.2 | ^10.0| | MIT | |
| v1.0.1 | ^7.3| | ^8.0| | MIT | |
| v1.0.0 | ^7.3| | ^8.0| | MIT |