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.
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
composer require phpstreamserver/http-server
php server.php start
<?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 is it different from PHP-FPM?
Your application remains loaded between requests instead of starting again for every request, reducing repeated startup work.
Can I run an existing PHP application?
Not always without changes. Applications must be designed for an always-in-memory runtime rather than assuming a fresh start for every request.
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?
You do not need PHP-FPM. PHPStreamServer keeps your application running and serves requests directly. Nginx is also optional, although you may still choose to use it 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.