aef/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.
2,362
Install
composer require aef/laravel-batch-requests
Latest Version:v1.1.0
PHP:^8.2
License:MIT
Last Updated:Aug 19, 2025
Links: GitHub  ·  Packagist
Maintainer: ahmedabdelnaby

Laravel Batch Requests

Latest Version on Packagist Total Downloads License

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

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v1.1.0 ^8.2 ^10.0|^11.0|^12.0 MIT
v1.0.1 ^7.3|^8.0 ^8.0|^9.0|^10.0|^11.0 MIT
v1.0.0 ^7.3|^8.0 ^8.0|^9.0|^10.0 MIT