Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Api Rest Utils Laravel Package

everycheck/api-rest-utils

A Symfony utility package offering a JSON response builder with common API statuses and custom headers, plus a paginated repository trait for filtering, ordering, and searching entities across joins.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Verdict: reference implementation only — do not adopt as a dependency.

  • Architecture fit: The package is explicitly a Symfony utility library ("utils we use in every api rest project under symfony"), not a Laravel package. It bundles two concerns: a ResponseBuilder that emits Symfony\Component\HttpFoundation\Response objects with JSON bodies, and a Doctrine repository trait for filtered/ordered pagination. Neither is Laravel-idiomatic: the README examples use Symfony's service container ($this->get('jms_serializer')), Doctrine's EntityManager/getRepository(), and Symfony Form error parsing. In a Laravel codebase you would be importing a foreign architecture for two small pieces of plumbing that Laravel already solves natively (response()->json(), API Resources, LengthAwarePaginator, query scopes).
  • Integration feasibility: Low-to-moderate. Laravel's Illuminate\Http\Response extends Symfony's Response, and Laravel's router will normalize a returned Symfony response — so a naive return (new ResponseBuilder(...))->ok($data); would technically render. But the constructor's hard dependency on a JMS Serializer instance (uncommon in Laravel) and the Doctrine-bound trait mean you'd be fighting the framework on both halves. The pragmatic path is a fork-and-port, not an install.
  • Technical risk: High, and concentrated in provenance rather than complexity:
    • Archived, 1 star, 0 dependents — no upstream maintenance, no security response, no issue triage. You inherit full ownership on day one.
    • Maturity signals are all red: "readme" is the only maturity marker; no CHANGELOG, no versioning policy, no visible test suite, no CI badge, no contributing guide.
    • Composer constraint risk: Symfony 2.x/3.x-era code is likely pinned to symfony/http-foundation versions that conflict with Laravel 10/11 (Symfony 6/7). An composer require may simply fail resolution, or force a downgrade elsewhere in the tree.
    • Unverifiable license — must be confirmed before any code is copied into a fork.
    • Unassessed filter/pagination safety — the pagination trait builds filters from request input; without source review there is a real possibility of unparameterized DQL or missing allow-listing, i.e. SQL injection surface.
  • Key questions to answer before any decision:
    1. What is the declared license, and does it permit forking into a proprietary codebase?
    2. What PHP and symfony/http-foundation version constraints does composer.json declare?
    3. Is the JMS Serializer dependency injectable/mockable, or is it baked into every response path?
    4. Does the pagination trait allow-list filter fields and parameterize values, or concatenate them into DQL?
    5. Are the status codes and error envelopes (formError, forbiddenAcl, conflict) aligned with our existing API contract, or will they introduce a fourth error shape?
    6. Is there any hidden coupling to Doctrine event listeners, JMS serialization groups, or Symfony bundles not shown in the README?

Integration Approach

  • Stack fit: Poor as a library, acceptable as a pattern. The response verb surface (ok, created, deleted, notFound, badRequest, unauthorized, forbidden, conflict, formError) is a reasonable API error taxonomy that most teams converge on anyway; the value is the naming convention, not the implementation. The addHeaders() fluent pattern is trivially reproducible as a Laravel Response macro or a small ApiResponse facade.
  • Recommended migration path (port, don't install):
    1. Do not add to composer.json. Treat the repo as a design reference and a source of copy-paste candidates.
    2. Reimplement the response layer (~150–250 LOC) as App\Http\ApiResponse using response()->json($payload, $status, $headers) with a consistent envelope: { data, meta } on success, { error: { code, message, details } } on failure. Wire it into the exception handler so ModelNotFoundException, AuthorizationException, and ValidationException map to notFound / forbidden / formError equivalents automatically.
    3. Replace JMS Serializer with Laravel API Resources (JsonResource / ResourceCollection). This removes the single most awkward dependency in the package and gets you conditional relationships, pagination metadata, and sparse fieldsets for free.
    4. Replace the Doctrine pagination trait with Eloquent query scopes — a Filterable trait plus ->when($request->filled('sort'), ...) and ->paginate(). Critically, implement a field allow-list rather than translating request keys directly into orderBy / where columns.
    5. Deprecate and document the mapping table from the old Symfony helper names to the new Laravel helpers so any Symfony service being ported translates mechanically.
  • Compatibility: Assume the package targets PHP 5.x/7.x and Symfony 2.8/3.x until composer.json proves otherwise. If any Laravel service needs to co-exist, verify symfony/http-foundation resolution first — this is the single most likely hard blocker to a straightforward require.
  • Sequencing: (1) license and source audit → (2) composer constraint spike in a throwaway branch → (3) port ResponseBuilder to ApiResponse + exception handler mapping → (4) port serialization to API Resources → (5) port pagination to Eloquent scopes with allow-listing → (6) add contract tests on status codes and envelope shape → (7) delete the package reference. Total estimate: 3–5 engineer-days for a small team, most of it in contract tests rather than code.

Operational Impact

  • Maintenance: You are the maintainer from commit one. Because the package is archived, there is no upgrade path, no security patch channel, and no upstream to file issues against. The offsetting factor is size: two concerns, roughly one response class and one repository trait. Forking under an org namespace, adding PHPStan + a small Pest/PHPUnit suite, and pinning it internally is a few days of work — but it is permanent work you would not have if you simply wrote the equivalent natively.
  • Support: Zero community support, 1 star, 0 dependents — no Stack Overflow corpus, no third-party blog posts, no peers to compare behavior with. Any knowledge lives in the source. Budget for internal documentation of the error-envelope contract, since the README documents method names but not payload shapes, status codes, or header-casing behavior.
  • Scaling: Runtime cost is negligible — ResponseBuilder is stateless and allocation-only, so throughput impact is noise against serialization and DB time. The real scaling concerns are inherited from the design: (a) JMS Serializer is materially slower and heavier than Laravel's native JSON encoding for large collections; (b) a dynamic filter/order trait without index-aware allow-listing will produce full-table scans and unpredictable query plans as tables grow; (c) uniform JSON errors on every path means no streaming or partial-response optimization — fine for CRUD, a ceiling for high-volume exports.
  • Failure modes to plan for:
    • composer update breaking on a Symfony major bump (package pinned to EOL components) — likely the first incident.
    • Container/serializer not registered → hard 500 on every endpoint rather than a graceful fallback.
    • Unparameterized filters → SQL injection or, milder, 500s on unexpected column names.
    • Inconsistent error envelopes if some endpoints use the helper and others use Laravel's default exception rendering — clients then need two parsers.
    • Silent contract drift: status code choices (conflict vs badRequest) are conventions with no tests enforcing them, so they will diverge across services.
  • Ramp-up: Very low for reading, moderate for trusting. A mid-level engineer can absorb the entire functional surface in under an hour — the README plus one source file. The cost is reverse-engineering the undocumented parts (exact payload keys, JMS serialization groups, header handling, pagination metadata format), which is where integration surprises live. Pair the port with contract tests so behavior is pinned by assertions rather than by one engineer's memory.

Bottom line for a TPM: the score (0.0025), archived status, single-digit stars, zero dependents, and Symfony-only scope all point the same direction — this is a small piece of prior art worth 30 minutes of reading and zero lines in composer.json. Extract the API verb taxonomy and the fluent header pattern, reimplement them natively in Laravel, and close the item.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator