Skip to main content

Application server and process manager for modern PHP applications.

PHPStreamServer is an event-loop-based application server and process supervisor built entirely in PHP.

Its extensible plugin system provides HTTP application serving, task scheduling, and process supervision within a unified runtime, without requiring Nginx, PHP-FPM, Cron, or Supervisor.

Powered by the Revolt event loop and the AMPHP ecosystem, it enables asynchronous, concurrent execution in PHP applications.

Preview: PHPStreamServer is under active development and is not yet production-ready.

Features

Built Entirely in PHP

No separate web server, process manager, or scheduler is required. Install it with Composer and run it with PHP.

Always in Memory

Keeps your application loaded between requests, reducing startup overhead and improving response times.

Asynchronous HTTP Server

Serve applications directly with built-in support for HTTP/2, HTTPS, gzip compression, static files, and middleware.

Worker Lifecycle Management

Automatically restart workers based on memory usage, maximum lifetime, request count, or unhandled exceptions.

Flexible Task Scheduler

Run recurring tasks using cron expressions, fixed intervals, or specific date and time schedules.

External Process Supervision

Run and supervise non-PHP programs alongside PHP workers from the same unified runtime.

Configurable Log Routing

Route logs by channel and severity to files, stdout and stderr, syslog, or Graylog.

Prometheus Metrics

Expose server performance metrics and register custom metrics for application-specific monitoring.

Development File Monitoring

Automatically reloads workers when monitored files change, so code updates take effect immediately during development.

Extensible Plugin System

Enable built-in plugins or create custom ones to add project-specific functionality.

Quick Start

Install PHPStreamServer and start a simple HTTP server with the following minimal configuration.
Install via Composer
composer require phpstreamserver/http-server
Start the server
php server.php start
View Documentation
server.php
<?php

use Amp\Http\Server\HttpErrorException;
use Amp\Http\Server\Request;
use Amp\Http\Server\Response;
use PHPStreamServer\Core\Server;
use PHPStreamServer\Plugin\HttpServer\HttpServerPlugin;
use PHPStreamServer\Plugin\HttpServer\Worker\HttpServerProcess;

$server = new Server();

$server->addPlugin(
new HttpServerPlugin(), // Register the HTTP server plugin
);

$server->addWorker(
new HttpServerProcess(
listen: '0.0.0.0:8080', // Address to listen on
count: 2, // Number of worker processes
onRequest: static function (Request $request): Response {
return match ($request->getUri()->getPath()) {
'/' => new Response(body: 'Hello world'),
default => throw new HttpErrorException(404),
};
}
),
);

exit($server->run());