PHPackages                             befuture/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. befuture/api-response

ActiveLibrary[API Development](/categories/api)

befuture/api-response
=====================

Standardized JSON API response helper for Laravel &amp; PHP.

v1.0.0(5mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Nov 29Pushed 5mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

befuture/api-response
=====================

[](#befutureapi-response)

 [![PHP Version](https://camo.githubusercontent.com/06ceba693a6738ec5a569f8a2e9226cd3af695f87d6426223feaf4e44c753e4c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e312d626c7565)](https://camo.githubusercontent.com/06ceba693a6738ec5a569f8a2e9226cd3af695f87d6426223feaf4e44c753e4c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e312d626c7565) [![Tests](https://camo.githubusercontent.com/9519c4ca959d3753af769b4ec3e942d1bb7e2c70ab94a2bfd10755f318900b15/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6265667574757265696e2f6170692d726573706f6e73652f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)](https://camo.githubusercontent.com/9519c4ca959d3753af769b4ec3e942d1bb7e2c70ab94a2bfd10755f318900b15/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6265667574757265696e2f6170692d726573706f6e73652f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473) [![Laravel Package](https://camo.githubusercontent.com/f139e14a949191bbfc53a8c778515707dd25a2d72b3206338a361d7413ab1cfb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d5061636b6167652d6f72616e6765)](https://camo.githubusercontent.com/f139e14a949191bbfc53a8c778515707dd25a2d72b3206338a361d7413ab1cfb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d5061636b6167652d6f72616e6765) [![MIT License](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)](https://camo.githubusercontent.com/5caa455d8debc46fb23abbadb45a733a937f3910a73fc875c2f7820468e1bb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e)

A lightweight and standardized API JSON response package for Laravel and standalone PHP projects.

Features
--------

[](#features)

- Unified JSON response structure for success and error cases
- HTTP status code / internal code / message / data / meta fields
- Auto-discovery support for Laravel
- Standalone PHP usage via factory class
- Fully tested with PHPUnit
- GitHub Actions CI workflow included

Example JSON Structure
----------------------

[](#example-json-structure)

```
{
  "success": true,
  "code": "OK",
  "message": "Operation completed successfully.",
  "data": {
    "id": 1,
    "name": "Example"
  },
  "meta": {
    "request_id": "abc-123",
    "runtime_ms": 12
  }
}
```

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

[](#installation)

```
composer require befuture/api-response
```

If the package is not published on Packagist yet, you may load it via VCS repository inside your `composer.json`.

Laravel Integration
-------------------

[](#laravel-integration)

The package supports Laravel auto-discovery.
If you prefer manual registration:

```
// config/app.php
'providers' => [
    BeFuture\ApiResponse\ApiResponseServiceProvider::class,
],
```

Optional Facade:

```
'aliases' => [
    'ApiResponse' => BeFuture\ApiResponse\Facades\ApiResponse::class,
],
```

### Usage

[](#usage)

```
use BeFuture\ApiResponse\ApiResponse;

// Success response
return ApiResponse::success(
    data: ['id' => 1],
    message: 'Success'
);

// Error response
return ApiResponse::error(
    message: 'An error occurred.',
    code: 'UNEXPECTED_ERROR',
    httpStatus: 500
);

// Validation error
return ApiResponse::validationError($validator->errors()->toArray());
```

Framework-Independent Usage
---------------------------

[](#framework-independent-usage)

```
use BeFuture\ApiResponse\ApiResponseFactory;

$factory = new ApiResponseFactory();

$responseArray = $factory->success(
    data: ['foo' => 'bar'],
    message: 'OK'
);

header('Content-Type: application/json');
http_response_code($responseArray['_status']);
echo json_encode($responseArray['body']);
```

Running Tests
-------------

[](#running-tests)

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

This project is licensed under the MIT License.
See `LICENSE` for details.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance70

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

170d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/befuture-api-response/health.svg)

```
[![Health](https://phpackages.com/badges/befuture-api-response/health.svg)](https://phpackages.com/packages/befuture-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)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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