Replace ServerStartCommand with WorkerRunner

FrankenPHP workers are PHP files started by the frankenphp binary, not console commands.
Extract the frankenphp_handle_request() loop into Http\WorkerRunner so apps can use it
directly from worker.php. Remove src/Command/ as it's no longer needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 16:22:02 +03:00
parent 98a4094c5e
commit df1d2a58bf
2 changed files with 21 additions and 9 deletions

35
src/Http/WorkerRunner.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace Pronchev\Pinecore\Http;
use Pronchev\Pinecore\ExceptionHandler;
final class WorkerRunner
{
public function __construct(
private readonly HttpApplication $app,
private readonly ExceptionHandler $exceptionHandler,
) {}
public function run(): void
{
$maxRequests = (int) ($_SERVER['MAX_REQUESTS'] ?? 0);
for ($n = 0; !$maxRequests || $n < $maxRequests; ++$n) {
$keepRunning = frankenphp_handle_request(function (): void {
try {
$this->app->handleRequest($_GET, $_POST, $_COOKIE, $_FILES, $_SERVER);
} catch (\Throwable $e) {
$this->exceptionHandler->handleException($e);
}
});
$this->app->terminate();
gc_collect_cycles();
if (!$keepRunning) {
break;
}
}
}
}