Boost PHP Performance with PRipple: A Native Coroutine Framework

PRipple is a high‑performance native PHP coroutine framework built on PHP 8.1 fibers and the Revolt library, offering simple APIs for asynchronous I/O, seamless integration with popular PHP frameworks, and easy installation via Composer for developing concurrent, high‑load applications.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Boost PHP Performance with PRipple: A Native Coroutine Framework

PRipple is a high‑performance native PHP coroutine framework built on PHP 8.1 fibers and the Revolt library, offering a simple API for developing concurrent network and data‑intensive applications.

Key Features

High performance through native coroutines, boosting concurrency.

Compatibility with existing PHP frameworks and libraries; works in FPM/CLI environments.

100 % PHP implementation, no extra extensions required.

Coroutine scheduling using Fiber and Promise mechanisms.

Asynchronous I/O for network and file operations.

Supports high‑concurrency request handling for real‑time or heavy‑load scenarios.

Easy integration with traditional projects and simple installation.

Additional Characteristics

Native : built entirely with PHP’s native coroutine support.

Ecosystem : compatible with most Composer packages.

Integration : seamless with Laravel, Symfony, ThinkPHP, Yii, etc., without code changes.

Runtime Mechanics

Overview

All asynchronous closures defined in PRipple are driven by an EventLoop. The loop executes events at the appropriate time, so developers only need to control the flow; closures may run in different context spaces, and developers must avoid coroutine or process escape.

Main Process Runtime

Typical users do not interact directly with the main runtime; their code runs inside the event‑loop and coroutine contexts. The entry point of the process creates the PRipple runtime before the framework driver, e.g., the Laravel entry file.

<?php
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
}
require __DIR__.'/../vendor/autoload.php';

// TODO: main process runtime
\P\async(function () {
    // TODO: coroutine runtime, including Laravel middleware/service providers/controllers
    (require_once __DIR__.'/../bootstrap/app.php')
        ->handleRequest(Request::capture());
});
# start PRipple
\P\tick();

Installation

Composer

composer require cclilshy/p-ripple-drive

Webman Configuration

Configure config/server.php file
<?php
return [
    // ...
    'event_loop' => \Psc\Drive\Workerman\PDrive::class,
];

Usage

Manual Creation

public function index(Request $request): string
{
    $handle = new \Psc\Plugins\Guzzle\PHandler([
        'pool' => 1 // enable HTTP keep‑alive
    ]);
    $client = new \GuzzleHttp\Client(['handle' => $handle]);

    // Send request without blocking other processes
    $response = $client->get('http://www.baidu.com');
    return $response->getBody()->getContents();
}

Global Usage (Recommended)

public function index(Request $request): string
{
    $client = \P\Plugin::Guzzle();

    // Send request without blocking other processes
    $response = $client->get('http://www.baidu.com');
    return $response->getBody()->getContents();
}

Demo

use function P\async;
use function P\await;

/**
 * @desc method description
 * @param Request $request
 * @return string
 */
public function index(Request $request): string
{
    for ($i = 0; $i < 100; $i++) {
        async(function () use ($i) {
            $response = await(\P\Plugin::Guzzle()->getAsync('https://www.qq.com/'));
            $time = microtime(true);
            $responseStatusCode = $response->getStatusCode();
            var_dump("[{$time}] request {$i} status: {$responseStatusCode}");
        });
    }
    return 'Open source tech stack!';
}
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performancePHPFrameworkcoroutineasync I/O
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.