Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"nyholm/psr7": "^1.4",
"nyholm/psr7-server": "^1.0",
"psr/http-server-middleware": "^1.0",
"react/async": "@dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the dev version of this package?

"react/http": "^1.5",
"symfony/runtime": "^5.3"
},
Expand Down
11 changes: 7 additions & 4 deletions src/SyncRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7Server\ServerRequestCreator;
use React\EventLoop\Loop;
use function React\Async\async;

final class SyncRunner
{
Expand All @@ -31,11 +32,13 @@ public function __construct(Application $application, SapiEmitter $sapi)

public function run(): int
{
$this->sapi->emit(
$this->application->handle($this->responseFactory->fromGlobals())
);

$loop = Loop::get();
async(function (): void {
$this->sapi->emit(
$this->application->handle($this->responseFactory->fromGlobals())
);
});

$loop->run();

return 0;
Expand Down