Application server and process manager for modern PHP applications.

PHPStreamServer is a high-performance, event-loop-based application server and supervisor for PHP, written in PHP.
Powered by the Revolt event loop and built on the AMPHP ecosystem, it brings true asynchronous capabilities to PHP applications.
With its extensible plugin system, PHPStreamServer can replace traditional stacks such as Nginx, PHP-FPM, Cron, and Supervisor.

Features

Runs on PHP
No additional software is required—PHPStreamServer runs entirely on PHP. Just install via Composer and get started!
Always-in-memory
Keeps applications loaded in memory for enhanced performance and faster response times.
Asynchronous HTTP Server
Built-in HTTP server with support for HTTP/2, HTTPS, GZIP, static file serving, and middleware.
Advanced Worker Management
Includes worker reload strategies triggered by TTL, memory usage, or exceptions.
Flexible Scheduler
Schedule tasks like Cron jobs with customizable intervals.
Support for External Programs
Manage non-PHP applications alongside PHP workers seamlessly.
Powerful Logging System
Log to files, stdout/stderr, syslog, or Graylog with advanced log routing.
Prometheus Metrics Support
Exposes a metrics endpoint for monitoring server performance and tracking custom application metrics.
File Monitoring for Development
Automatically reloads workers when file changes are detected, making it ideal for development.
Plugin System
Extend functionality with built-in plugins, or create custom ones to fit your needs.

Quick Start

Get up and running with PHPStreamServer in just a few lines of code. Here's a simple HTTP server example to get you started.
Install via composer
$ composer require phpstreamserver/http-server
Run your server
$ php server.php start
View Full Documentation
server.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());