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 currently in 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

require __DIR__ . '/vendor/autoload.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\HttpServerWorker;

$server = new Server();

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

$server->addWorker(
new HttpServerWorker(
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());

FAQ

How does it differ from PHP-FPM?

In a traditional PHP-FPM setup, a web server forwards each request to PHP-FPM and the application is initialized for that request. PHPStreamServer runs the AMPHP HTTP server in long-running workers and keeps the application loaded between requests.

Can I run an existing PHP web application?

Not always without changes. Applications must be designed for an always-in-memory runtime, and code that relies on PHP globals such as $_GET and $_POST must be adapted to use request objects instead.

Does my application need to be asynchronous?

No. Applications can remain synchronous when running on PHPStreamServer.

Can I use asynchronous PHP in my application?

Yes. PHPStreamServer is built around the Revolt event loop and AMPHP, so building asynchronous PHP applications is the most natural way to use it.

How is PHPStreamServer installed?

Composer is all you need to install PHPStreamServer. There is no separate server binary or additional service to set up; you configure and launch it with PHP.

Do I need Nginx or PHP-FPM?

No. PHPStreamServer keeps your application running and serves requests directly. Nginx can still be used as a reverse proxy.

Can it replace Cron and Supervisor?

PHPStreamServer includes a scheduler for recurring tasks and a process supervisor for PHP workers and external commands, so separate Cron or Supervisor services are not required.

How do code changes take effect during development?

Because application code stays in memory between requests, changes require a worker reload. The optional file monitor automatically reloads workers when monitored files change.