sakshsky/laravel-api-optimizer

A Laravel package to optimize API resources with sparse fieldsets, caching, and more.

dev-main 2025-05-12 08:46 UTC

This package is not auto-updated.

Last update: 2025-05-13 07:00:09 UTC


README

Latest Version on Packagist Total Downloads License

Laravel API Resource Optimizer enhances Laravel's API Resource classes with advanced optimization features like sparse fieldsets, conditional relationship loading, and response caching, making your REST APIs faster and more flexible.

Features

  • Sparse Fieldsets: Request specific fields (e.g., GET /users?fields=id,name).
  • Conditional Relationship Loading: Include related data (e.g., GET /users?include=posts).
  • Response Caching: Cache API responses to reduce database queries.
  • Schema Validation: Validate requested fields and includes.
  • Rate-Limiting: Protect endpoints with throttling.

Requirements

  • PHP 8.0 or higher
  • Laravel 8.x, 9.x, or 10.x
  • Composer

Installation

Install via Composer:

composer require sakshsky/laravel-api-optimizer