Skip to content

Commit 689a6c6

Browse files
committed
Clarify example code
1 parent 48bfdaf commit 689a6c6

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/plugins/http-server.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ $server = new Server();
2424

2525
$server->addPlugin(
2626
new HttpServerPlugin(
27-
// HttpServerPlugin configuration
27+
// Optional. HttpServerPlugin configuration
2828
),
2929
);
3030

3131
$server->addWorker(
3232
new HttpServerProcess(
3333
// HttpServerProcess configuration
34-
name: 'Web Server',
35-
count: 2,
36-
listen: '0.0.0.0:8080',
34+
name: 'Web Server', // Worker name
35+
listen: '0.0.0.0:8080', // Address to listen on
36+
count: 2, // Number of worker processes
3737
onRequest: function (Request $request, HttpServerProcess $worker): Response {
3838
return match ($request->getUri()->getPath()) {
3939
'/' => new Response(body: 'Hello world'),

docs/plugins/logger.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use PHPStreamServer\Core\Server;
1616
use PHPStreamServer\Core\Worker\WorkerProcess;
1717
use PHPStreamServer\Plugin\Logger\Handler\ConsoleHandler;
1818
use PHPStreamServer\Plugin\Logger\LoggerPlugin;
19+
use Psr\Log\LoggerInterface;
1920

2021
$server = new Server();
2122

@@ -29,7 +30,11 @@ $server->addWorker(
2930
new WorkerProcess(
3031
name: 'Worker process',
3132
onStart: function (WorkerProcess $worker): void {
32-
$worker->logger->info('Hello from worker', ['pid' => \posix_getpid()]);
33+
$logger = $worker->container->getService(LoggerInterface::class);
34+
$logger->info('Hello from worker', ['pid' => \posix_getpid()]);
35+
36+
// You can also use the logger like this:
37+
// $worker->logger->info('Hello from worker', ['pid' => \posix_getpid()]);
3338
},
3439
),
3540
);

0 commit comments

Comments
 (0)