betalabs/laravel-api-handler
betalabs/laravel-api-handler is a Laravel package for building consistent JSON APIs, centralizing response formatting and exception handling so controllers stay clean and endpoints return predictable, standardized results.
Architecture fit
_fields, _with, filters, sort, pagination, fulltext search) and shapes an API envelope with meta/counts. It introduces no persistence, queue, or infrastructure footprint beyond the request path.Integration feasibility
^8.2 and Laravel ^10 || ^11 || ^12 (CI target: PHP 8.5, Laravel 12). This is a modern, narrow window — feasible only if the consuming application has already completed its runtime modernization.Technical risk
master (2023) is being left behind. That is a recovery signal, not a stability signal — it suggests a very small maintainer team and a repository that was dormant. No security policy, LTS commitment, or support window is documented.die() and a 200 on an unsupported polymorphic _with, emit extra bindings in CountMetaProvider causing MySQL HY093, and throw TypeError on native fulltext without _fields. Teams currently on 4.x may be serving incorrect status codes and silently broken counts today. This is the strongest argument for upgrading, independent of the version bump._with on an unsupported relation now returns 400 ApiHandlerException instead of a 200 with body text. This is correct behavior, but it is an observable API contract change for any client that tolerated the old response, and it will surface in monitoring as a new 4xx class._with, _fields, filters) is the classic over-posting/data-leak vector if the package does not enforce allowlists. The release notes do not state whether allowlisting is built in or left to the consumer.Key questions
native fulltext MySQL-specific, and what is the supported database matrix?Stack fit
Migration path
Compatibility
illuminate/* constraint will not resolve.composer.lock, and confirm the app's own CI covers PHP 8.2/8.3 — not just the 8.5 the upstream targets.Sequencing
GROUP BY), nested _fields/_with, fulltext, and the unsupported-relation case.400 on unsupported relations.Maintenance
Support
Scaling
_fields/_with nesting depth, restrict relations and sortable columns to allowlists, bound page size, and require indexes on filterable/sortable columns.GROUP BY); cache or make them opt-in on high-traffic list endpoints.native fulltext depends on database FULLTEXT indexes — profile before enabling on large tables.Failure modes
400 ApiHandlerException — monitorable and correct, but it may break clients that relied on the old 200.die()-with-200 behavior meant errors previously looked like successes; any dashboards or alerts tuned to that will need re-baselining, and the new 4xx spike at rollout should be expected, not alarming.HY093 binding and TypeError classes are addressed; verify against the app's actual database engine and fulltext configuration rather than assuming parity.Ramp-up
_with/_fields, filter semantics, envelope/meta shape, and fulltext modes takes about two to three days including edge-case debugging.400 semantics — since that is where most integration friction will land.How can I help you explore Laravel packages today?