PHPackages                             jnilla/joomla-request-batcher - 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. jnilla/joomla-request-batcher

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

jnilla/joomla-request-batcher
=============================

Send and process requests in batches

v0.0.3(4y ago)012MITJavaScript

Since Oct 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jnilla/joomla-request-batcher)[ Packagist](https://packagist.org/packages/jnilla/joomla-request-batcher)[ Docs](https://github.com/jnilla/joomla-request-batcher)[ RSS](/packages/jnilla-joomla-request-batcher/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

joomla-request-batcher
======================

[](#joomla-request-batcher)

Send and process requests in batches.

Send multiple requests in batches to reduce the overhead of sending multiple requests individually.

Installation (Server Side)
--------------------------

[](#installation-server-side)

Install using Composer:

```
$ composer require jnilla/joomla-request-batcher

```

Load the library using the Composer autoloader:

```
require('vendor/autoload.php');

```

Installation (Client Side)
--------------------------

[](#installation-client-side)

This library depends on jQuery. Include the file `request-batcher.js` after jQuery and before your code. Example:

```

```

Basic Usage (Client Side)
-------------------------

[](#basic-usage-client-side)

The request batcher uses the namespace:

```
Jnilla.Joomla.RequestBatcher

```

Basic configuration:

```
// If true prints debug data to the console
Jnilla.Joomla.RequestBatcher.setDebug(true);

// Sends a batch every 5 seconds
Jnilla.Joomla.RequestBatcher.setBatchInterval(5);

// Set the server URL where you want to sent the data to. If not set the default value is the current page URL.
Jnilla.Joomla.RequestBatcher.setServerUrl('?index.php?option=com_example&task=ajax.processRequest');

```

Add one request to the actual batch

```
Jnilla.Joomla.RequestBatcher.addRequest(
    // Request data (Must be string type)
	'some data',
	// Response callback
	function(responseData){console.log(responseData);}
);

```

The `addRequest` method has a mechanism to prevent duplicated requests.

The batcher does nothing if the actual batch has no requests.

Basic Usage (Server Side)
-------------------------

[](#basic-usage-server-side)

Declaration:

```
use Jnilla\Joomla\RequestBatcher as RequestBatcher;

```

The `process` method process the batch executing a callback for each request in the actual batch.

```
// Process the batch
RequestBatcher::process(function($requestData){ // Callback for each request
    // Some code here
});

```

Example
-------

[](#example)

On the client side we got an script that displays the value of one product (A) every 2 seconds, and the value of another product (B) every 10 seconds.

```
Jnilla.Joomla.RequestBatcher.setBatchInterval(1);  Send batches every 1 seconds
Jnilla.Joomla.RequestBatcher.setServerUrl('?index.php?option=com_example&task=ajax.processRequest'); // Server URL

// Add the 'Product A' request every 2 seconds.
setInterval(function(){
    Jnilla.Joomla.RequestBatcher.addRequest(
        // Request data. Only send string. That is why we used stringify
    	JSON.stringify({'task': 'getProductA'}),
    	// Response callback
    	function(responseData){
        	console.log('Product Name:'+responseData.name+', Value:'+responseData.value');
        	// Output: Product Name: Product A, Value: $100
    	}
    );
}, 2000);

// Add the 'Product B' request every 10 seconds.
setInterval(function(){
    Jnilla.Joomla.RequestBatcher.addRequest(
        // Request data.
    	JSON.stringify({'task': 'getProductB'}),
    	// Response callback
    	function(responseData){
        	console.log('Product Name:'+responseData.name+', Value:'+responseData.value');
        	// Output: Product Name: Product B, Value: $350
    	}
    );
}, 10000);

```

The abtches are send every 1 seconds, but the requests are added at different interval. You can play with the batch interval and how ofthen they are added to meet your needs. For this example some times nothing is send because the batch is empty, some times the batch has 1 request and some times the batch has 2 requests.

On the server side we can implement a structure like this that resembles a task based controller.

```
// Process the batch
RequestBatcher::process(function($requestData){ // Callback for each request
    $requestData = json_decode($requestData); Parse the JSON string
    switch ($requestData->task){
			case 'getProductA':
			    // Some code here
			    $data = ['name'=> 'Product A' , 'value' => '$100'];
			    // The response must be string type. That is why we used json_encode()
			    $data = json_encode($data);
				return $data;
			case 'getProductB':
			    // Some code here
			    $data = ['name'=> 'Product B' , 'value' => '$350'];
			    $data = json_encode($data);
				return $data;
	}
});

```

The server response is send automatically after the batch is processed.

As simple as it is.

License
-------

[](#license)

This project is under the MIT License.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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 ~99 days

Total

4

Last Release

1721d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57fd06b6b69b2a42631897f0c2b340457fac86624597b12df906690c64831076?d=identicon)[jnilla](/maintainers/jnilla)

---

Top Contributors

[![jnilla](https://avatars.githubusercontent.com/u/965514?v=4)](https://github.com/jnilla "jnilla (9 commits)")

---

Tags

requestjoomlabatcher

### Embed Badge

![Health badge](/badges/jnilla-joomla-request-batcher/health.svg)

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

###  Alternatives

[joomlatools/composer

A Composer plugin to install Joomla extensions into your installation.

5332.9k24](/packages/joomlatools-composer)

PHPackages © 2026

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