outrightvision/api-model
Outrightvision's api-model adds an API-ready base model for Laravel, simplifying how Eloquent resources are exposed, queried, and transformed for JSON endpoints—handy for teams building consistent, filterable REST APIs without repeating boilerplate.
Architecture fit. The package is a read-only JSON-to-PHP hydration layer, not a generator. It fits exactly one architectural slot: the inbound edge where a Laravel app consumes someone else's JSON (partner feed, CRM, HRIS, payments) and the payload is deeply nested and relational. It does not fit write paths, round-trip serialization, request construction, endpoint scaffolding, or domain modelling. Any business case premised on "ship endpoints faster" should be corrected before funding; the defensible case is "make partner payloads legible, reviewable, and cheap to change at the boundary."
Integration feasibility. Low technical lift, high discipline cost. composer require and done — no service provider, no config to publish, no migrations, no assets. The engineering work is authoring App\Api\Models: ten-to-thirty-line classes per upstream resource using $cast_model, hasOne/belongsTo/hasMany, cast_dates/date_timezone, $requiredParameters, and included_default. Transport is explicitly out of scope — you own HTTP, retries, and caching via Http, Guzzle, or Saloon. A two-to-three-day spike against real payloads is the right size of bet before committing.
Technical risk. Material, and it is concentrated in maintenance rather than correctness:
$requiredParameters is thin — effectively "this model must exist," not field-level validation.@property docblocks on every class.cast_dates routes through Carbon::parse(); empty strings, ambiguous formats, and timezone-less timestamps behave unpredictably.Key questions for the team.
spatie/laravel-data already a house standard, and does this create a competing convention?Stack fit. Laravel/PHP only, and the entire value proposition is that the access pattern is already familiar to an Eloquent-fluent team — $user->company->geo->lat instead of $data['company']['geo']['lat'] ?? null. Verify the package against your current Laravel major before planning; no compatibility matrix is published. The absence of a service provider cuts both ways: clean (nothing auto-wires) but hostile to "install and go" expectations.
Migration path. Greenfield work at the boundary is trivial. For existing ad-hoc array spelunking, introduce App\Api\Models behind a thin internal interface — an ApiGateway, per-integration repository, or plain service returning native arrays or your own DTOs — so nothing downstream imports the package directly. Refactor per integration, not big-bang. This single design choice converts a four-star dependency into a reversible one: swapping to laravel-data later becomes a one-file change.
Compatibility. Confirm the release timestamp against the actual tag, run the package on your target Laravel version during the spike, and vendor immediately — MIT licensing makes a fork in packages/ or a Composer repositories entry trivial and free. Treat it as your own code the moment it appears in anything that matters.
Sequencing.
laravel-data DTO. Exit criteria: the Eloquent ergonomics win clearly, or you've lost two days instead of a quarter.$cast_model for the nested object. Verify $user->company->geo->lat.tests/fixtures/, asserting every field the app touches plus every relation. This is the only defence against silent drift.@property docblocks from class one. Retrofitting across a dozen models is tedious; static analysis is lost otherwise.hasMany, then cast_dates with date_timezone validated against a genuine response, then included_default where a collection's relation is walked on every item.Http::retry(3, 100)->get(...)->json(), cache, then hydrate.Maintenance. Assume ownership. The practical mitigation is vendoring the small surface you depend on — the base class is readable in one sitting, which makes a fork a low-effort, high-control move rather than a last resort. Budget a named owner and a small recurring allowance for Laravel major upgrades and upstream schema changes.
Support. No community answers, no tutorials, no upstream SLA, no dependents to learn from. Every question lands on your team. This is acceptable for internal tooling, admin surfaces, prototypes, and timeboxed integration spikes; it is not acceptable on a customer-facing SLA path where maintenance risk cannot be absorbed.
Scaling. No published performance data. Dynamic property resolution and lazy hydration across large collections carry real, unmeasured cost. included_default is the mitigation but must be verified against your payload shape rather than assumed. Benchmark on an actual page of payloads before wiring this into any hot path.
Failure modes to plan for.
null and looks identical to a legitimately absent optional field. Compensating control: contract tests per model, not per integration, plus $requiredParameters on models that must exist.cast_dates and date_timezone defaults against genuine responses before trusting them.Ramp-up. Near-zero for anyone fluent in Eloquent; that is the strongest practical argument for adoption in a Laravel shop. New engineers read a whole API contract on one screen in a 10–30 line class. Two onboarding artifacts are non-negotiable: the @property docblock convention and the explicit warning that unknown fields return null silently. Without the second, the first schema drift incident will be diagnosed as a bug in the integration rather than a change at the vendor.
How can I help you explore Laravel packages today?