Home

Awesome

<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/phpstreamserver/.github/refs/heads/main/assets/phpss_core_light.svg"> <img alt="PHPStreamServer logo" align="center" width="70%" src="https://raw.githubusercontent.com/phpstreamserver/.github/refs/heads/main/assets/phpss_core_dark.svg"> </picture> </p>

PHPStreamServer — PHP Application Server

PHP >=8.2 Version Downloads

PHPStreamServer is a high performance, event-loop based application server and process supervisor for PHP written in PHP. As the core component of PHPStreamServer, this module is responsible for comprehensive worker management.

Features

Requirements and limitations

Install

$ composer require phpstreamserver/core

Configure

Here is an example of a simple supervisor server configuration.

// server.php

use PHPStreamServer\Core\Plugin\Supervisor\ExternalProcess;
use PHPStreamServer\Core\Plugin\Supervisor\WorkerProcess;
use PHPStreamServer\Core\Server;

$server = new Server();

$server->addWorker(
    new WorkerProcess(
        name: 'Supervised Program',
        count: 1,
        onStart: function (WorkerProcess $worker): void {
            // custom long running process
        },
    ),
    new ExternalProcess(
        name: 'External supervised program',
        count: 1,
        command: 'sleep 600'
    ),
);

exit($server->run());

Run

$ php server.php start