eleven-labs/api-validator
PHP library for validating PSR-7 HTTP requests and responses against OpenAPI/Swagger 2.0 schemas. It checks headers, query parameters, URI, and body using JSON Schema, helping ensure API messages conform to your specification.
Architecture fit. Despite being filed under a Laravel/PHP package, eleven-labs/api-validator is not Laravel-native — it is a framework-agnostic schema library that validates PSR-7 requests against a Swagger 2.0 description, backed by justinrainbow/json-schema. Architecturally that makes it a contract-enforcement layer sitting in front of the application, not a replacement for Laravel's FormRequest/Validator stack. In a Laravel context this means inserting it as middleware, which requires a PSR-7 bridge (symfony/psr-http-message-bridge plus a PSR-7 implementation such as nyholm/psr7). That extra hop is the single biggest architectural fit consideration: Laravel hands you an Illuminate\Http\Request (Symfony HttpFoundation), not a PSR-7 message, so every request pays a conversion cost and every body-stream edge case (file uploads, chunked bodies, already-consumed streams) becomes our problem.
Integration feasibility. Feasible for a spike, questionable for a committed dependency. The library only supports Swagger 2.0 — not OpenAPI 3.x — which is the dominant spec version for any API designed in the last several years. If our specs are 3.x, this package is either unusable or requires a conversion step (spec downgrade) that introduces its own drift risk. The dependency on justinrainbow/json-schema is a positive: it is a mature, widely used validator, so the core validation semantics are trustworthy even if the wrapper is thin.
Technical risk. High, driven by project health rather than code quality:
Key questions to answer before adoption.
master?$ref resolution, allOf/oneOf, formData/multipart, and non-JSON content types handled?Stack fit. The package belongs at the HTTP boundary as a middleware, with the Swagger document loaded once and cached (config-cached or a compiled/cached validator instance) rather than parsed per request. It should be positioned as a contract guardrail alongside — not instead of — existing Laravel validation. Runtime enforcement and CI-time contract testing are two distinct use cases; the second is lower-risk and delivers most of the value.
Migration path. Do not cut over directly. Sequence:
FormRequest rules. This surfaces false positives (the main operational hazard) before they can break traffic.league/openapi-psr7-validator, cebe/php-openapi, swagger-php) before locking in.Compatibility. Two hard gates: (a) spec version — Swagger 2.0 only; (b) PSR-7 bridge compatibility with the current Symfony/Laravel HTTP stack. Note that the bridge converts the request body into a stream, and Laravel middleware ordering matters — validation must run before controllers consume input, and must not interfere with file uploads or php://input reads.
Sequencing. Treat this as a time-boxed evaluation, not an adoption. Run it in parallel with an assessment of maintained OpenAPI 3.x validators. If the alternative wins on compatibility, the spike cost is still repaid by the contract-testing pattern established.
Maintenance. The dominant risk. Zero dependents and 24 stars imply effectively no community backstop; if the maintainer goes quiet (or already has), we own the code. Budget for an internal fork or vendored copy, plus a named owner. Any fork must track justinrainbow/json-schema upstream for security patches.
Support. Documentation is README-only — no cookbook, no error catalogue, no Stack Overflow footprint. Onboarding support will be internal-only; escalation to the vendor is unlikely to be responsive.
Scaling. Parsing and $ref-resolving a large Swagger document per request is a real latency and memory cost. Mitigation is mandatory spec caching and, ideally, pre-compiled validators. Validation itself adds CPU per request; at high throughput this needs measurement, not assumption. Large specs with deep $ref graphs are the worst case.
Failure modes.
Ramp-up. Low-to-moderate for engineers familiar with OpenAPI concepts; the PSR-7 layer and Swagger 2.0 (as opposed to OpenAPI 3.x) semantics are the friction points. Expect the team to spend more time on the bridge, caching, and error-surface design than on the validator itself.
Verdict. The high opportunity score (4.64) reflects a genuine gap — spec-driven request validation in PHP is under-served — but this package's low maturity, Swagger 2.0-only scope, and zero dependents make it a research spike, not a production dependency. Recommend: evaluate it as a reference implementation for contract-testing patterns, benchmark against a maintained OpenAPI 3.x validator, and only adopt with a fork-and-own commitment plus shadow-mode rollout.
How can I help you explore Laravel packages today?