PHPackages                             mahmoud-birdsol/api-responses - 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. mahmoud-birdsol/api-responses

ActiveLibrary[API Development](/categories/api)

mahmoud-birdsol/api-responses
=============================

A responsable set of classes for resource api request

1.8(5y ago)0192MITPHPPHP ^7.0CI failing

Since Aug 31Pushed 5y ago2 watchersCompare

[ Source](https://github.com/mahmoud-birdsol/laravel-api-responses)[ Packagist](https://packagist.org/packages/mahmoud-birdsol/api-responses)[ RSS](/packages/mahmoud-birdsol-api-responses/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

Api Responses
=============

[](#api-responses)

[![Build Status](https://camo.githubusercontent.com/0c1ed69f605714305dde3abe5262efa0e50468cb1471ec955b01b4fca64185fc/68747470733a2f2f7472617669732d63692e6f72672f6d61686d6f75642d62697264736f6c2f6c61726176656c2d6170692d726573706f6e7365732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mahmoud-birdsol/laravel-api-responses) [![StyleCI](https://camo.githubusercontent.com/2d36f1797cb27b5e66a9ac657090f8dc8ab0aa1408e2a3128fa18455ecbc1ea4/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134363934313336322f736869656c643f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/2d36f1797cb27b5e66a9ac657090f8dc8ab0aa1408e2a3128fa18455ecbc1ea4/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134363934313336322f736869656c643f6272616e63683d6d6173746572)

This package is a response helper classes for laravel api developers to use with transformers the package we use for transformers is [spatie/laravel-fractal](https://github.com/spatie/laravel-fractal) you will find some helper classes in this package for all rest api end points but the try value is in the Index response.

- Index Response
- Show Response
- Updated Response
- Deleted Response
- Created Response

### Installation

[](#installation)

```
composer require mahmoud-birdsol/api-responses

```

**Config**Paginator adapter can be configured, as well as the paginate request key.

```
 php artisan vendor:publish --provider="Alacrity\Responses\Providers\ResponseServiceProvider"

```

```
/**
 * Pagination config variables.
 */
'pagination_adapter' 	 	  => \League\Fractal\Pagination\IlluminatePaginatorAdapter::class,
'pagination_request_key' 	  => 'paginate',

```

### Usage

[](#usage)

**Index Response**

To return an index response from your controller you can just return a new instance of the class and pass through an eloquent model query builder and transformer. It's specifically designed that way so you can add any default queries you need to run on the model for example an authorization restriction scope that needs to exist on the model query level or a multi-tenant application in the same db you would filter the class from the backend.

```
return new IndexResponse(User::query(), new UserTransformer());

```

**Front end usage**You can use request params to manipulate this response through some ready made functions.

- **Pagination** you can send a paginate=10 to get a paginated response from the api.
- **Filters** you can use eloquent scopes to filter for example filter by user id and you have a scope method on your model `public function scopeUser($query, $userId)` you can easily use this from your frontend by sending a request with `user={id}`.
- **Sorting** You can sort response data also from your frontend by just passing through `latest=true` or `sortAsc=email` or `sortDesc=id` and just sort using any attribute you would like to use.

**Show Response**

A show response is just a simple class that will transform your data using fractal and return it to the user.

```
return new ShowResponse($model, new ModelTransformer());

```

**Updated Response**

The updated response is very similar to the show response except that will refresh the updated model behind the scene so you can do something like this in your controller method easily.

```
public function update($request, User $user)
{
    $user->update($request->all());

    return new UpdatedResponse($user, new UserTransformer());
}

```

### License

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/spatie/laravel-fractal/blob/master/LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~106 days

Recently: every ~149 days

Total

8

Last Release

2069d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16209999?v=4)[Mahmoud Mokhtar](/maintainers/mahmoud-birdsol)[@mahmoud-birdsol](https://github.com/mahmoud-birdsol)

---

Top Contributors

[![mahmoud-birdsol](https://avatars.githubusercontent.com/u/16209999?v=4)](https://github.com/mahmoud-birdsol "mahmoud-birdsol (21 commits)")[![LyonelZ](https://avatars.githubusercontent.com/u/4537547?v=4)](https://github.com/LyonelZ "LyonelZ (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mahmoud-birdsol-api-responses/health.svg)

```
[![Health](https://phpackages.com/badges/mahmoud-birdsol-api-responses/health.svg)](https://phpackages.com/packages/mahmoud-birdsol-api-responses)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[echolabsdev/prism

A powerful Laravel package for integrating Large Language Models (LLMs) into your applications.

2.3k388.3k10](/packages/echolabsdev-prism)[sburina/laravel-whmcs-up

WHMCS API client and user provider for Laravel

271.3k](/packages/sburina-laravel-whmcs-up)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
