- How do I install juampi92/api-resources in a Laravel app?
- Install it with a single composer require juampi92/api-resources; it is a Composer-only dependency with no migrations, queues, or infrastructure to provision. Adoption is opt-in per Resource class, so you can introduce it on one endpoint before rolling it out across your API. Pin ^1.10 and reconcile that constraint against your laravel/framework version to avoid conflicts with other illuminate-dependent packages such as auth, permission, or admin-panel packages.
- Which Laravel and PHP versions does juampi92/api-resources support?
- Version 1.10.0 added Laravel 11.x compatibility, and the package is used with Laravel 9 and 10 on modern PHP 8.x runtimes. The ceiling matters: nothing in the v1.10.0 release claims Laravel 12 or PHP 8.4 support, so do not assume forward compatibility. Check the composer.json require block for the PHP floor and any ext-* constraints before pinning, since CI no longer masks platform requirements with --ignore-platform-reqs.
- How do sparse fieldsets work with juampi92/api-resources?
- Clients send a fields query parameter to select which attributes appear in the response, and the package applies that selection on top of your existing Laravel Resource definitions instead of requiring separate serializers. Your resource classes stay clean and reusable because field selection is handled at the presentation layer. Treat the allowed field list as an explicit contract so newly added model attributes are not exposed by accident.
- How do I support nested includes via query parameters in Laravel APIs?
- The package reads an include query parameter and loads the requested relationships in combination with Laravel's Eloquent API Resources, so clients ask for exactly the relationships they need instead of you hardcoding them per endpoint. Because it composes with Laravel Resources rather than replacing them, you can adopt it incrementally on the endpoints that benefit most. Keep an explicit allow-list of addressable relationships so nested includes cannot be used to traverse relationships you never meant to expose.
- Can clients filter collections using query parameters with this package?
- Yes, filtering is part of the query-string controls the package adds alongside sparse fieldsets and nested includes. Filtering is applied in the presentation and query layer, so you still need to validate and allow-list which filters a client may send. Because client-controlled query strings change response bodies, review cache keys and CDN or gateway caching rules before enabling these parameters broadly.
- Does juampi92/api-resources replace Laravel's Eloquent API Resources?
- No. It is a presentation-layer package layered on top of Laravel's Eloquent API Resources and does not touch persistence, schema, or infrastructure. You keep writing Resource classes, and the package adds query-driven behaviour such as relationship includes and sparse fieldsets. This means existing resources can coexist with package-driven ones, so you can migrate endpoint by endpoint rather than replacing your serialization layer wholesale.
- Is juampi92/api-resources safe to use in production?
- Architecturally it fits cleanly in the HTTP layer, and blast radius is limited because adoption is opt-in per Resource class. The real risks are governance rather than plumbing: a single maintainer, a small contributor base, and compatibility work that has arrived reactively rather than pre-emptively. Pin ^1.10, audit the require block after the CI change, and define which fields and relationships are externally addressable before exposing them to clients.
- How actively maintained is juampi92/api-resources, and is there a support policy?
- It is a single-maintainer project with a small contributor base, and v1.10.0 was a compatibility-and-hygiene release: Laravel 11 support arrived through an external contributor's first pull request and --ignore-platform-reqs was removed from CI. No breaking changes, deprecations, or config changes were announced, which is consistent with a minor SemVer bump. Because framework support has lagged releases, expect similar lag for future Laravel majors and track releases instead of assuming forward compatibility.
- How does API versioning work with juampi92/api-resources?
- The package is built to help you manage versioned responses while keeping resource definitions consistent and reusable, with clients controlling which fields and includes they receive. Versioning itself still lives in your routing and resource organisation, since the package does not enforce a versioning policy for you. That makes it a good fit when you want to evolve responses additively instead of maintaining a separate serializer fork per API version.
- What are the alternatives to juampi92/api-resources for query-driven API responses?
- Spatie's laravel-query-builder is the common alternative, applying filters, sorts, and includes to Eloquent queries and returning models or paginators. juampi92/api-resources instead targets the serialization layer, adding sparse fieldsets and nested includes on top of Laravel's Eloquent API Resources. Choose the resource-centric option if your API is already organised around Resource classes and you want client-driven field selection without re-shaping queries separately, and evaluate both against your caching, pagination, and contract-testing setup.