Skip to content

Commit cfc1275

Browse files
committed
Readme update
1 parent af78cef commit cfc1275

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

README.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@
1010
[![Version](https://img.shields.io/github/v/tag/luzrain/phpstreamserver?label=Version&filter=v*.*.*&sort=semver&color=374151)](../../releases)
1111
[![Tests Status](https://img.shields.io/github/actions/workflow/status/luzrain/phpstreamserver/tests.yaml?label=Tests&branch=master)](../../actions/workflows/tests.yaml)
1212

13-
PHPStreamServer is a high performance event-loop based process manager, TCP, and UDP server written in PHP.
14-
With a built-in PSR-7 HTTP server you can easily integrate any PSR-7 compatible framework with it in no time.
15-
The built-in HTTP server is memory efficient no matter how large your HTTP requests and responses you operate are.
16-
PHPStreamServer is supports TLS encryption and the ability to implement custom protocols.
13+
> [!NOTE]
14+
> This package is now under development
15+
16+
PHPStreamServer is a high performance event-loop based process manager, scheduler and webserver written in PHP.
17+
This application server is designed to replace traditional setup for running php applications such as nginx, php-fpm, cron, supervisor.
1718

1819
#### Key features:
19-
- Supervisor;
20+
- Process manager;
21+
- Scheduler;
2022
- Workers lifecycle management (reload by TTL, max memory, max requests, on exception, on each request);
21-
- PSR-7 HTTP server;
23+
- HTTP/2
2224

2325
#### Requirements and limitations:
2426
- Unix based OS (no windows support);
2527
- php-posix and php-pcntl extensions;
26-
- php-uv extension is not required, but highly recommended for better performance.
28+
- php-uv extension is not required, but recommended for better performance.
2729

2830
## Getting started
2931
### Install composer packages
@@ -37,30 +39,32 @@ Here is example of simple http server.
3739
```php
3840
// server.php
3941

40-
use Luzrain\PHPStreamServer\Exception\HttpException;
42+
use Amp\Http\Server\HttpErrorException;
43+
use Amp\Http\Server\Request;
44+
use Amp\Http\Server\RequestHandler\ClosureRequestHandler;
45+
use Amp\Http\Server\Response;
4146
use Luzrain\PHPStreamServer\Internal\WorkerProcess;
42-
use Luzrain\PHPStreamServer\Listener;
47+
use Luzrain\PHPStreamServer\Plugin\HttpServer\HttpServer;
48+
use Luzrain\PHPStreamServer\Plugin\HttpServer\Listen;
4349
use Luzrain\PHPStreamServer\Server;
44-
use Luzrain\PHPStreamServer\Server\Connection\ConnectionInterface;
45-
use Luzrain\PHPStreamServer\Server\Http\Psr7\Response;
46-
use Luzrain\PHPStreamServer\Server\Protocols\Http;
47-
use Psr\Http\Message\ServerRequestInterface;
50+
use Luzrain\PHPStreamServer\WorkerProcessDefinition;
4851

4952
$server = new Server();
50-
$server->addWorkersProcess(new WorkerProcess(
53+
54+
$server->addWorkersProcess(new WorkerProcessDefinition(
5155
name: 'HTTP Server',
5256
onStart: function (WorkerProcess $worker) {
53-
$worker->startListener(new Listener(
54-
listen: 'tcp://0.0.0.0:80',
55-
protocol: new Http(),
56-
onMessage: function (ConnectionInterface $connection, ServerRequestInterface $data): void {
57-
$response = match ($data->getUri()->getPath()) {
58-
'/' => new Response(body: 'Hello world'),
59-
'/ping' => new Response(body: 'pong'),
60-
default => throw HttpException::createNotFoundException(),
61-
};
62-
$connection->send($response);
63-
},
57+
$requestHandler = new ClosureRequestHandler(function (Request $request) : Response {
58+
return match ($request->getUri()->getPath()) {
59+
'/' => new Response(body: 'Hello world'),
60+
'/ping' => new Response(body: 'pong'),
61+
default => throw new HttpErrorException(404),
62+
};
63+
});
64+
65+
$worker->startPlugin(plugin: new HttpServer(
66+
listen: new Listen(listen: '0.0.0.0:8087'),
67+
requestHandler: $requestHandler,
6468
));
6569
},
6670
));

0 commit comments

Comments
 (0)