Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Update worker docs - fix worker sample #145

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/en/php/worker.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use Nyholm\Psr7\Factory\Psr17Factory;
use Spiral\RoadRunner\Worker;
use Spiral\RoadRunner\Http\PSR7Worker;


// Create new RoadRunner worker from global environment
$worker = Worker::create();

Expand All @@ -49,9 +48,12 @@ $factory = new Psr17Factory();

$psr7 = new PSR7Worker($worker, $factory, $factory, $factory);

while (true) {
do {
try {
$request = $psr7->waitRequest();
if ($request === null) {
break;
}
} catch (\Throwable $e) {
// Although the PSR-17 specification clearly states that there can be
// no exceptions when creating a request, however, some implementations
Expand Down Expand Up @@ -81,7 +83,7 @@ while (true) {
// of the request failed.
$psr7->getWorker()->error((string)$e);
}
}
} while (isset($request));
```

This worker expects communication with the RoadRunner server over standard pipes.
Expand Down Expand Up @@ -232,4 +234,4 @@ interacting with RoadRunner.

## What's Next?

1. [Plugins — Server](../plugins/server.md) - Read more about RoadRunner server plugin.
1. [Plugins — Server](../plugins/server.md) - Read more about RoadRunner server plugin.