PHPackages                             quetzal-studio/laravel-api-response - 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. quetzal-studio/laravel-api-response

ActiveLibrary[API Development](/categories/api)

quetzal-studio/laravel-api-response
===================================

Custom API Response for Laravel

v0.2.1(2y ago)095MITPHPPHP ^7.4|^8.0

Since Jan 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kangata/laravel-api-response)[ Packagist](https://packagist.org/packages/quetzal-studio/laravel-api-response)[ RSS](/packages/quetzal-studio-laravel-api-response/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laravel API Response
====================

[](#laravel-api-response)

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

[](#installation)

`composer require quetzal-studio/laravel-api-response`

Usage
-----

[](#usage)

### With array

[](#with-array)

```
$user = [
    'id' => 1,
    'name' => 'Ata',
];

return api_response($user);

// result
{
  "data": {
    "id": 1,
    "name": "Ata"
  },
  "time": 4,
  "code": 200,
  "message": "Successful"
}
```

### With model

[](#with-model)

```
$user = Model::first();

return api_response($user);

// result
{
  "data": {
    "id": 1,
    "name": "Ata"
  },
  "time": 4,
  "code": 200,
  "message": "Successful"
}
```

### With body

[](#with-body)

#### User body class

[](#user-body-class)

```
use QuetzalStudio\ApiResponse\Body;

$body = Body::make(code: 404, message: 'Not Found');

return api_response($body)->status(404);

// result
{
  "time": 6,
  "code": 404,
  "message": "Not Found",
  "data": null
}
```

#### Use make\_body function

[](#use-make_body-function)

```
return api_response(
    make_body(code: 404, message: 'Not Found')
)->status(404);

// result
{
  "time": 6,
  "code": 404,
  "message": "Not Found",
  "data": null
}
```

#### Use withBody method

[](#use-withbody-method)

```
return api_response()->withBody([
    'code' => 403,
    'message' => 'Forbidden',
    'data' => [
        'ip' => '127.0.0.1',
    ],
])->status(403);

// result
{
  "data": {
    "ip": "127.0.0.1"
  },
  "time": 6,
  "code": 403,
  "message": "Forbidden"
}
```

Change response keys
--------------------

[](#change-response-keys)

```
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Response::setupBodyKeys([
            'code' => 'status_code',
            'message' => 'status_message',
            'data' => 'result',
        ]);
    }
```

Exclude some keys
-----------------

[](#exclude-some-keys)

```
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Response::excludeBodyKeys(['time', 'code']);
    }
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~172 days

Total

3

Last Release

873d ago

PHP version history (2 changes)v0.1.0PHP ^7.4

v0.2.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebd2172197cb09856d4fc78f1791a59884b7c844e066e641a790c269f31fc720?d=identicon)[kangata](/maintainers/kangata)

---

Top Contributors

[![kangata](https://avatars.githubusercontent.com/u/12477588?v=4)](https://github.com/kangata "kangata (4 commits)")

### Embed Badge

![Health badge](/badges/quetzal-studio-laravel-api-response/health.svg)

```
[![Health](https://phpackages.com/badges/quetzal-studio-laravel-api-response/health.svg)](https://phpackages.com/packages/quetzal-studio-laravel-api-response)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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