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

View File

@@ -35,7 +35,7 @@ HTTP → Caddy (:80) → /worker.php → FrankenPHP worker loop
| Path | Purpose |
|---|---|
| `src/Kernel.php` | One-time bootstrap |
| `src/Http/` | `HttpApplication`, `Request`, `Response`, `Router`, `RouteDefinition`, `MiddlewarePipeline`, `HttpException` |
| `src/Http/` | `HttpApplication`, `WorkerRunner`, `Request`, `Response`, `Router`, `RouteDefinition`, `MiddlewarePipeline`, `HttpException` |
| `src/Console/` | `ConsoleApplication`, `ConsoleRouter`, `ConsoleInput`, `ConsoleOutput`, `ConsoleDefinition` |
| `src/Auth/` | `JwtService`, `AuthMiddleware`, `AuthContext`, `AuthException`, `UserProviderInterface` |
| `src/Log/` | `StdoutLogger`, `FileLogger`, `CompositeLogger`, `NullLogger` |
@@ -45,6 +45,23 @@ HTTP → Caddy (:80) → /worker.php → FrankenPHP worker loop
| `src/Config.php` | Static config loader: `Config::get('section.key')` |
| `src/ContainerFactory.php` | Builds PHP-DI container from `config/services.php` |
## Worker entrypoint
FrankenPHP запускается бинарником (`frankenphp run --config Caddyfile`), который сам стартует PHP-воркеры. `worker.php` приложения должен:
```php
use Pronchev\Pinecore\Kernel;
use Pronchev\Pinecore\Http\WorkerRunner;
require __DIR__ . '/vendor/autoload.php';
Kernel::boot(__DIR__);
Kernel::container()->get(WorkerRunner::class)->run();
```
`WorkerRunner` резолвится через DI autowiring, конфигурировать не нужно.
`MAX_REQUESTS` env var ограничивает число запросов на воркер (0 = без лимита).
## HTTP
```php