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
Laravel Resource Reducer

Laravel Resource Reducer Laravel Package

shipsaas/laravel-resource-reducer

Laravel Resource Reducer trims API resource payloads so you only return the fields a client actually needs. Define lean, reusable resource classes, cut response size and query overhead, and keep your JSON output consistent across endpoints.

View on GitHub
Deep Wiki
Context7

Resource Reducer optimizes your API endpoint responses by return what consumers need, defer execution and no more BIG FAT JSON.

Frequently asked questions about Laravel Resource Reducer
What is shipsaas/laravel-resource-reducer used for in Laravel?
It is an optional payload-shaping utility for Laravel API responses. It trims fields, relationships, and nested resources so endpoints return only what a client requests instead of a big JSON payload. It works at the JsonResource presentation layer and is not a replacement for resource classes, serialization contracts, or authorization.
How do I install laravel-resource-reducer?
Install it with Composer in a Laravel application and use v1.1.1 as the first reliable baseline because that patch corrects missing composer.json configuration. After install, verify package discovery and autoloading in a clean Laravel skeleton before wiring it into an endpoint. Confirm the package Laravel and PHP version constraints first.
Which Laravel and PHP versions does laravel-resource-reducer support?
The provided context does not list explicit Laravel or PHP version constraints, so check the package composer.json before adding it to an application. Treat v1.1.1 as the baseline and test a clean Composer install on your target Laravel version. Do not assume compatibility with older or newer framework releases without verification.
What is the allowlist or denylist syntax for selecting fields?
The exact fluent API and allowlist or denylist syntax are not specified in the available context, so review the package README and source before implementation. The package is described as using lean, reusable resource classes to trim fields, relationships, and nested resources. Document your reducible-field policy and cover it with response-shape tests.
Does laravel-resource-reducer reduce database queries or prevent N+1 problems?
It is positioned as a response-shaping helper, so do not assume it reduces database load automatically. You need to confirm whether dropped relationships prevent eager loading or only hide data that was already loaded. Reducing JSON size can improve bandwidth and client rendering, but query optimization still belongs in your resource and query layer.
Can per-request field selection break my API contract?
Yes, per-request field selection can cause contract drift, inconsistent client behavior, and cache-key complexity if defaults are not explicit. Version client-facing schemas and document which fields are reducible before enabling it. Add response-shape contract tests and pilot on one non-critical read-only endpoint behind a feature flag.
Does laravel-resource-reducer replace Laravel API Resources or authorization?
No. It fits alongside existing JsonResource classes as a presentation helper that trims output, and it should not replace serialization contracts or authorization logic. Field selection must be safe by default, and authorization still needs to be enforced in your application.
Is laravel-resource-reducer safe to use in production?
Direct runtime risk is low if you apply it narrowly to response shaping, but product risk is medium due to low adoption signals such as 46 stars and the last release on 2024-03-13. Pin the version, track upstream issues, and avoid making it a critical dependency for core API contracts. Require internal documentation for supported versions, configuration, reducible fields, and rollback.
How should I migrate an existing Laravel API to resource reduction?
Start with a short spike in a disposable Laravel app, inventory target JsonResource classes, and classify fields as safe-to-trim versus contract-critical. Update to v1.1.1, refresh the lockfile, clear config and package caches, and verify package discovery. Baseline existing API contracts, add response-shape tests, pilot one endpoint behind a feature flag, then expand endpoint by endpoint.
How does field selection interact with API response caching?
Cache keys must include the requested field set, or cached responses may be reused incorrectly across clients that asked for different fields. Because reduction changes response shape per request, caching needs to account for the selected reducible fields. Monitor payload size, error rates, and client compatibility after rollout.
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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo