roadrunner-php/roadrunner-api-dto
Pre-generated PHP DTO classes for RoadRunner’s API Protocol Buffers. Use in your project to make RPC calls to RoadRunner plugins (HTTP, Jobs, KV, Lock, Status, WebSockets, etc.) without regenerating protobuf code.
Start by installing the package via Composer:
composer require roadrunner-php/roadrunner-api-dto
The package provides no runtime logic—it’s only a collection of auto-generated, typed DTO classes that mirror RoadRunner’s internal protocol (e.g., jobs, responses, errors, metadata). Your first use case is likely in a custom RoadRunner worker (e.g., HTTP server, queue consumer, or gRPC service). For example, when handling an HTTP job:
use RoadRunnerAPI\Dto\Http\Request;
// In your worker loop
$job = $worker->waitJob();
$requestDto = Request::fromArray($job->getPayload());
// Now $requestDto->getMethod(), ->getUri(), ->getHeaders(), etc.
Check src/ (via GitHub) or run composer show roadrunner-php/roadrunner-api-dto --path to see available DTOs (e.g., Http\Request, Http\Response, Jobs\Job, Http\Error, Values\Headers, etc.).
json_decode($payload, true) with typed DTOs to avoid fragile array access and improve IDE autocomplete.// Example: Logging middleware
$request = Http\Request::fromArray($job->getPayload());
$logger->info('HTTP request', [
'method' => $request->getMethod(),
'path' => $request->getUri()->getPath(),
]);
$response = (new Http\Response())
->withStatus(200)
->withHeader('Content-Type', 'application/json')
->withBody(json_encode(['data' => $item]));
$worker->respond($response->toArray());
class OrderProcessedJob extends Jobs\Job {}) to enforce domain contracts.spiral/roadrunner or spiral/roadrunner-http. You’ll still need a RoadRunner worker client to send/receive jobs.roadrunner-api-dto version aligns with your RoadRunner binary and worker SDK (e.g., spiral/roadrunner ≥2.0 vs ≥3.0 have different payloads). Mismatch can cause UndefinedProperty or deserialization errors.?string/?int. Use null checks or null-coalescing before accessing (e.g., $request->getHeaders()?->get('Host')), especially for optional headers or metadata.class MyRequest extends Http\Request { public function getNormalizedPath(): string { ... } }), but avoid modifying the generated classes directly—they’re auto-updated.fromArray() throws InvalidPayloadException, inspect the raw payload ($job->getPayload()) and compare against the proto spec. Common culprits: snake_case vs camelCase keys, missing required fields (marked @required in PHPDoc), or wrong types (e.g., array where a scalar is expected).make generate or manual php bin/generate.php) when RoadRunner’s proto files update—this package likely ships pre-generated classes, so track changelogs for breaking changes.How can I help you explore Laravel packages today?