PHPackages                             reactphp-x/micro-service - 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. reactphp-x/micro-service

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

reactphp-x/micro-service
========================

v1.0.0(8mo ago)00MITPHP

Since Sep 5Pushed 8mo agoCompare

[ Source](https://github.com/reactphp-x/micro-service)[ Packagist](https://packagist.org/packages/reactphp-x/micro-service)[ RSS](/packages/reactphp-x-micro-service/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

ReactPHP X Micro Service
========================

[](#reactphp-x-micro-service)

A high-performance service distribution system built with ReactPHP, designed to distribute service calls across multiple master nodes efficiently and evenly.

Features
--------

[](#features)

- Even distribution of service calls across available master nodes
- Real-time load balancing based on call counts
- Input validation for service calls
- JSON-based API interface
- Built with ReactPHP for high performance and non-blocking I/O

Installation
------------

[](#installation)

Install via Composer:

```
composer require reactphp-x/micro-service -vvv
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- ReactPHP HTTP ^1.11
- ReactPHP X Register Center ^1.0

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use ReactphpX\MicroService\ServerMiddleware;
use ReactphpX\RegisterCenter\Register;
use React\Http\HttpServer;
use React\Socket\SocketServer;

// Initialize the register center
$register = new Register(8010);

// Create the server middleware
$middleware = new ServerMiddleware($register);

// Setup HTTP server
$server = new HttpServer($middleware);

// Listen on port 8080
$socket = new SocketServer('127.0.0.1:8080');
$server->listen($socket);
```

### Making Service Calls

[](#making-service-calls)

Send a POST request to your server with the following JSON structure:

```
{
    "server_calls": {
        "service_name1": [
            {
                "method": "methodName",
                "params": ["param1", "param2"]
            },
            {
                "method": "anotherMethod",
                "params": []
            }
        ],
        "service_name2": [
            {
                "method": "someMethod",
                "params": {"key": "value"}
            }
        ]
    }
}
```

### Response Format

[](#response-format)

For successful requests, you'll receive a response with the distributed calls:

```
{
    "service_name1": [
        "methodName" : result,
        "anotherMethod" : result
    ],
    "service_name2": [
        "someMethod" : result
    ]
}
```

For invalid requests, you'll receive a 400 Bad Request response:

error result

```
{
    "code": 1,
    "errorCode": 500,
    "msg": "Error description here",
    "data": null
}
```

success result

```
{
    "code": 0,
    "errorCode": 0,
    "msg": "Success",
    "data": {

    }
}
```

Error Handling
--------------

[](#error-handling)

The service validates all incoming requests and will return appropriate error messages for:

- Invalid server\_calls format (must be an array)
- Invalid service names (must be strings)
- Invalid call format (must be arrays with method and params)
- Missing or invalid method names
- Missing or invalid parameters

Load Distribution
-----------------

[](#load-distribution)

The service automatically distributes calls across available master nodes using the following strategy:

1. Maintains a count of calls per master node
2. Assigns new calls to the least loaded node
3. Ensures even distribution of load across all available nodes

License
-------

[](#license)

MIT

Author
------

[](#author)

wpjscc

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

255d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/76907477?v=4)[wpjscc](/maintainers/wpjscc)[@wpjscc](https://github.com/wpjscc)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/reactphp-x-micro-service/health.svg)

```
[![Health](https://phpackages.com/badges/reactphp-x-micro-service/health.svg)](https://phpackages.com/packages/reactphp-x-micro-service)
```

###  Alternatives

[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[sculpin/sculpin

Static Site Generator

1.5k102.8k12](/packages/sculpin-sculpin)[jclg/php-slack-bot

Slack bot user written in PHP

16825.5k1](/packages/jclg-php-slack-bot)[llm/mcp-server

PHP SDK for building MCP servers

431.1k](/packages/llm-mcp-server)[runtime/react

ReactPHP runtime

185.3k1](/packages/runtime-react)[octopoda/octopus

PHP Sitemap crawler

114.8k](/packages/octopoda-octopus)

PHPackages © 2026

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