PHPackages                             fallegahq/laravel-api-responder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. fallegahq/laravel-api-responder

ActiveLibrary[API Development](/categories/api)

fallegahq/laravel-api-responder
===============================

A comprehensive Laravel package for building consistent API responses with DTOs, caching, and role-based visibility

v1.2.4(4mo ago)015MITPHPPHP ^8.1|^8.2|^8.3

Since Dec 23Pushed 4mo agoCompare

[ Source](https://github.com/FallegaHQ/laravel-api-responder)[ Packagist](https://packagist.org/packages/fallegahq/laravel-api-responder)[ RSS](/packages/fallegahq-laravel-api-responder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (14)Versions (13)Used By (0)

Laravel API Responder
=====================

[](#laravel-api-responder)

A comprehensive Laravel package for building consistent, feature-rich API responses with DTOs, caching, role-based visibility, and more.

[![PHP Version](https://camo.githubusercontent.com/e0dcf1c5cee433a9401c24870138aaf2fd6f41aacdd1d34f198d13a141dd2b2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e31253743253545382e32253743253545382e332d626c7565)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/98b5b64b1789dbf3ac46406cf451b9a1c33500beab1840ca958d5a4fdb0eef9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531302e3025374325354531312e3025374325354531322e302d726564)](https://laravel.com)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE.md)

Features
--------

[](#features)

### Core Features

[](#core-features)

- 🎯 **Consistent API Responses** - Standardized JSON response structure
- 🔄 **DTO Transformation** - Attribute-based data transformation with PHP 8.1+ attributes
- 🔐 **Role-Based Visibility** - Control field visibility based on user roles
- ⚡ **Field-Level Caching** - Cache expensive computed fields automatically
- 📊 **Sparse Fieldsets** - Support for `?fields=id,name` query parameters
- 📄 **Automatic Pagination** - Built-in pagination support with metadata
- 🌍 **API Versioning** - Header-based API versioning
- 🎨 **Exception Handling** - Unified exception handling for Laravel 10, 11, and 12
- 📦 **Batch Operations** - Process multiple API requests in a single call
- 🧪 **Testing Helpers** - Fluent assertion helpers for API testing

### Advanced Documentation Generation

[](#advanced-documentation-generation)

- 📝 **OpenAPI 3.0 Generation** - Auto-generate complete API documentation
- 🔒 **Authentication Awareness** - Automatically detect and mark protected routes
- 🏷️ **Smart Tagging &amp; Grouping** - Organize endpoints with custom tags and groups
- 📖 **Human-Friendly Descriptions** - Document routes with intuitive attributes
- 🧪 **Test Coverage Validation** - Verify documentation accuracy with test integration
- 🔍 **Query Parameter Documentation** - Full validation rules (min, max, enum, format)
- 🔐 **Security Schemes** - Bearer token authentication included automatically
- 🎯 **Enum Support** - Auto-detects PHP enums and validation rules
- 🔗 **Nested DTOs** - Automatic relationship detection with `$ref` schemas
- 📎 **File Upload Documentation** - Multipart/form-data with constraints
- ⚠️ **Deprecation Warnings** - Mark deprecated endpoints in OpenAPI spec
- 🔍 **Route Filtering** - Include/exclude routes from public documentation

Requirements
------------

[](#requirements)

- PHP 8.1, 8.2, or 8.3
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

Install via Composer:

```
composer require fallegahq/laravel-api-responder
```

The package will auto-register via Laravel's package discovery.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=api-responder-config
```

This creates `config/api-responder.php` where you can customize all settings.

Quick Start
-----------

[](#quick-start)

### Laravel 12 Bootstrap Configuration

[](#laravel-12-bootstrap-configuration)

In your `bootstrap/app.php`:

```
