PHPackages                             kislayphp/gateway - 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. kislayphp/gateway

ActivePhp-ext[API Development](/categories/api)

kislayphp/gateway
=================

High-performance C++ PHP extension providing API gateway functionality with load balancing and routing for PHP microservices

v1.0.0(2w ago)021Apache-2.0ShellPHP &gt;=8.2CI passing

Since Feb 21Pushed 2w agoCompare

[ Source](https://github.com/KislayPHP/gateway)[ Packagist](https://packagist.org/packages/kislayphp/gateway)[ Docs](https://github.com/KislayPHP/gateway)[ RSS](/packages/kislayphp-gateway/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependenciesVersions (15)Used By (0)

KislayGateway
=============

[](#kislaygateway)

> Edge-only HTTP gateway for KislayPHP services. Route, apply lightweight edge policy, and forward requests without duplicating Core runtime behavior.

[![PHP Version](https://camo.githubusercontent.com/5fe05c705bf034839bda7651781e4d0a9d42f4a840478ca5e343873a0361bb89/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322b2d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/109222cb0d1f59ed2e77b56722653623fa45f93e2bb201a6eef8561d26a52185/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d677265656e2e737667)](LICENSE)![Release](https://camo.githubusercontent.com/714333c10797cbf68663465e6f09c3e45d245b1555ed8c28cc7492af64cc51a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d312e302e302d6f72616e67652e737667)

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

[](#installation)

**Via PIE (recommended):**

```
pie install kislayphp/gateway:1.0.0
```

Add to `php.ini`:

```
extension=kislayphp_gateway.so
```

New in 1.0.0
------------

[](#new-in-100)

- **Fixed a crash bug**: concurrent requests through service-registry/native-service routes could abort the whole process (Zend memory-manager corruption from calling PHP error-reporting APIs on a raw worker thread). Warning logging now goes straight to stderr instead.
- **Fixed a Host-header bug**: `registerService()` and `setFallbackTarget()` routes sent a blank `Host:` header upstream and never reused pooled connections — both now correctly compute their routing keys at registration time.
- Hot-path allocation reductions across the proxy request path (thread-local buffers for headers, method casing, and route lookups; a fast path for the common no-rewrite route case).
- In cross-language benchmarks, KislayPHP Gateway now beats Go's `httputil.ReverseProxy`, Node.js, and Spring Cloud Gateway on both throughput and tail latency for plain-proxy and JWT scenarios.
- **Known issue**: genuine multi-host round-robin (multiple distinct backends behind one `registerService()` pool) still collapses under real concurrency — not yet fixed, needs interactive debugger-level investigation. Single-backend service routes and static routes are unaffected.

Performance
-----------

[](#performance)

Plain proxy pass-through, wrk (2 threads, 20 connections, 3s + 5s warmup), 10-core reference machine, all gateways proxying to the same Node.js backend. Produced by `compare/run_gateway_compare.sh proxy`:

Gatewayreq/sp50p99vs KislayPHP**KislayPHP Gateway****80,306****119.5µs****236µs**—Node.js (native, cluster)54,073325µs2.76ms-32.7%Spring Cloud Gateway50,357347µs1.75ms-37.3%Go (httputil.ReverseProxy)45,903416µs1.14ms-42.8%Node.js (native, single process)35,433543µs1.08ms-55.9%Direct backend, no gateway in front (baseline): 130,591 req/s.

KislayPHP Gateway wins on both throughput and tail latency against every reverse proxy in the comparison, including Spring Cloud Gateway and Go's own `net/http/httputil.ReverseProxy`. Reproduce with `../compare/run_gateway_compare.sh` from the repo root, or the quick `../perf_smoke_test.sh` for a faster (and less statistically rigorous) sanity check. Note: this scenario uses a single backend — see the "Known issue" above for the current gap under genuine multi-host round-robin.

Role In The Stack
-----------------

[](#role-in-the-stack)

Gateway is the edge layer only.

- Gateway: route, optional edge auth, rate limit, circuit break, forward
- Core: request lifecycle, JWT state, tracing, async HTTP, business logic
- Discovery: resolve service name to healthy instance URL

Gateway does **not** reimplement Core's JWT state model or async HTTP engine.

Quick Start
-----------

[](#quick-start)

```
