spurwork/spectator
Spectator is a lightweight Laravel package for observing outgoing HTTP requests, letting you inspect, log, and assert on the calls your app makes so you can debug integrations and write reliable tests without hitting external APIs.
Architecture fit. Spectator (hotmeteor/spectator) is a development/test-time package for Laravel that validates HTTP tests against an OpenAPI 3.x specification. It sits at the test layer — not in the production request path — so it introduces no runtime coupling, no middleware in production, and no new infrastructure. Fit is strongest for teams that already treat an OpenAPI document as a contract (contract-first or spec-as-documentation) and weaker for teams with no spec or a hand-maintained one that has drifted. The v3.0.4 changes are consistent with that positioning: both fixes are confined to the test harness and the artisan command surface.
Integration feasibility. Low friction for a standard Laravel app: a --dev Composer dependency, a published config pointing at the spec file, and per-test opt-in via Spectator::using(...) or route middleware. The two fixes in this release reduce integration friction rather than add capability — the stdClass return for empty x-www-form-urlencoded bodies removes a spurious 500 when an endpoint accepts object-typed form payloads (a common shape for Laravel form posts), and the spectator:routes prefix fix means route listings now show the actual resolved URI, which materially helps when the spec is scoped under a prefix or API version group. Neither change alters the public API.
Technical risk. Assessment is based on release notes only; there is no prior internal evaluation and no usage data. Within that constraint, v3.0.4 is a patch release with no breaking changes and no deprecations, so upgrade risk from 3.0.x is minimal. The persistent risks are structural, not version-specific: (1) spec drift — the tool validates against your document, so a stale spec yields confident but meaningless green tests; (2) coverage illusion — only endpoints with Spectator-backed tests are checked, and coverage decays silently as routes are added; (3) validator strictness — OpenAPI validation is pedantic about nullable, oneOf, and content-type handling, which can surface as CI noise on legacy endpoints that are technically non-conforming; (4) maintainer concentration — small-team OSS package, so pin versions and be prepared to vendor or fork.
Key questions. Is the OpenAPI document the source of truth, or is it generated from code? Which OpenAPI version (3.0 vs 3.1) — behavior differs. What are the actual PHP/Laravel support bounds in composer.json versus our platform baseline? Is the spec complete enough that validation failures mean real defects rather than spec gaps? Do we have an owner for spec maintenance, or will it rot? Does CI currently run PHPUnit/Pest in a form where a new blocking assertion is politically acceptable?
Stack fit. Native to Laravel + PHPUnit or Pest; no separate service, container, or CI job. Composer dev-dependency, config file, spec file in the repo. Works alongside existing feature tests rather than replacing them, which keeps the incremental cost of adoption genuinely low.
Migration path. Adopt incrementally rather than retrofitting the whole API. A credible sequence is: (1) land the dependency and config with zero assertions, (2) wire a single well-understood endpoint — ideally a GET with a stable response schema — and get one green test, (3) add a non-blocking CI stage so failures are visible but don't gate merges, (4) expand to the endpoints under active change, (5) promote the CI stage to blocking once the pass rate is stable. For new endpoints, the cheapest pattern is spec-first: write the path and schemas before the controller, then let the tests enforce them from day one.
Compatibility. Drop-in upgrade from 3.0.3; both fixes are corrections to existing behavior and should not require test changes on our side. The stdClass fix could unblock tests that were previously failing or skipped against object-typed form endpoints, so expect a small number of newly passing (or newly revealed) tests after upgrade — worth a quick review rather than a blind bump. Confirm the PHP/Laravel support matrix against our platform baseline before committing to the v3 line at all, since we have no prior internal assessment on record.
Sequencing. Upgrade first (trivial, isolated) → validate against one endpoint → establish spec ownership → then expand. Do not sequence spec authoring and tooling adoption as one project; spec authoring is the long pole and should be scoped separately.
Maintenance. Two ongoing costs, only one of which is the package. The dependency itself is a dev-only Composer entry with a normal update cadence and semver-stable major line. The real cost is the OpenAPI document: it needs an owner, a review process, and discipline to update in the same PR as the endpoint change. If that ownership isn't assigned up front, the tool degrades into a green checkmark that validates nothing.
Support. Community-maintained, small contributor base, no commercial backing. Mitigations are cheap: pin to a known-good minor, review changelogs before bumping, and confirm the test suite still runs green after each upgrade. Budget a fallback plan (vendor the package) only if the spec becomes load-bearing for a regulated or public API.
Scaling. Cost scales linearly with the number of Spectator-backed tests and adds wall-clock time to the test suite, not to production traffic. There is no production footprint to scale. Large suites may eventually warrant splitting spec validation into a separate CI job or sharding tests, but that is a distant concern.
Failure modes. (a) False negatives — validator rejects a legitimate response shape, blocking CI; typically resolved by tightening the spec, which is the correct outcome but generates friction the first few times. (b) False positives — thin or permissive schemas (additionalProperties: true, loose types) pass while the contract is meaningless; the tool cannot detect this. (c) Coverage decay — new routes added without tests are silently unvalidated. (d) Harness-level breakage — v3.0.4's stdClass fix is an example of the class of bug where request/response construction in the test layer diverges from Laravel's real behavior and produces spurious 500s; these are contained to CI by construction, which is the argument for keeping the package strictly dev-only.
Ramp-up. A Laravel developer should reach a first green Spectator test in roughly half a day, most of it spent reading the package README and the OpenAPI spec rather than fighting the tooling. OpenAPI fluency is the longer pole — expect a couple of iterations before the team writes schemas that are strict enough to be useful and loose enough not to churn. A single engineer should own the spec and act as reviewer for schema changes; that role is what keeps the rest of the effort from decaying.
How can I help you explore Laravel packages today?