High-performance C++ PHP extension providing HTTP/HTTPS server with routing and middleware for PHP microservices

Maintainers

Package info

github.com/KislayPHP/core

Documentation

Language:Shell

Type:php-ext

Ext name:ext-kislayphp_extension

pkg:composer/kislayphp/core

Statistics

Installs: 57

Dependents: 1

Suggesters: 7

Stars: 1

Open Issues: 0

0.0.6 2026-03-20 19:31 UTC

This package is auto-updated.

Last update: 2026-03-21 04:26:55 UTC


README

PHP Version License Release

Kislay Core is the HTTP runtime for the KislayPHP ecosystem. It provides the embedded HTTP/HTTPS server, strict segment router, request/response lifecycle, middleware, async bridge, and Promise primitives used by the higher-level modules.

Install

pie install kislayphp/core:0.0.6
extension=kislayphp_extension.so

Build from source:

git clone https://github.com/KislayPHP/core.git
cd core
phpize
./configure --enable-kislayphp_extension
make -j4
sudo make install

Runtime contract

  • Routes support only static segments and :param segments.
  • Regex-style routes and wildcard route fragments are rejected at registration time.
  • Middleware uses function ($req, $res) and must return a truthy value to continue.
  • Query/body parsing is lazy.
  • listenAsync() requires ZTS. On NTS, run listen() in its own process.
  • AsyncHttp self-requests are rejected in single PHP runtime mode to avoid deadlocks.

Quick start

<?php

$app = new Kislay\Core\App();
$app->setOption('log', false);
$app->setOption('request_id', false);
$app->setOption('trace', false);

$app->use('/api', function ($req, $res) {
    $res->set('X-Powered-By', 'Kislay');
    return true;
});

$app->get('/api/users/:id', function ($req, $res) {
    $res->json([
        'id' => $req->param('id'),
        'search' => $req->query('q', ''),
    ], 200);
});

$app->post('/api/users/:id', function ($req, $res) {
    $res->json([
        'id' => $req->param('id'),
        'email' => $req->input('email'),
    ], 200);
});

$app->listen('0.0.0.0', 8080);

Request API

$req->param('id');
$req->query('name');
$req->input('email');
$req->getJson();
$req->header('authorization');

Async primitives

$app->setOption('async', true);
$app->setOption('async_threads', 4);

async(function () {
    return heavy_computation();
})->then(function ($result) {
    echo $result;
});

$http = new Kislay\Core\AsyncHttp();
$http->get('https://api.example.com/data');
$http->retry(2, 200);
$http->executeAsync()->then(function () use ($http) {
    echo $http->getResponseCode();
});

Performance notes

Validated locally for 0.0.6 on the current NTS reference machine with tracing, request-id generation, and request logging disabled:

  • /plaintext: 23789.89 req/s (ab -n 100000 -c 100)
  • /users/:id: 18915.87 req/s (ab -n 40000 -c 100)
  • /submit/:id: 12974.19 req/s (ab -n 20000 -c 50)
  • RSS remained flat across the sustained /plaintext stress run.

Native C++-only paths remain faster than PHP-routed paths. If you need materially higher PHP-route throughput than this NTS single-lane model provides, the next step is ZTS multi-runtime scaling rather than loosening Zend safety.

Production notes

  • Use Discovery for service resolution.
  • Use Gateway for edge routing and rate limiting.
  • Use Persistence for request-scoped transaction/runtime cleanup.
  • Keep request_id, trace, and log off in benchmark profiles unless you are measuring those features specifically.

Tests

php run-tests.php

Current local release-candidate result for 0.0.6:

  • 15 passed
  • 2 skipped (ZTS-only async coverage)
  • 0 failed

Support