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

ActiveLibrary[API Development](/categories/api)

drdre4life2/laravel-api-response
================================

A simple JSON response helper for Laravel 10+

v1.0.0(1y ago)05MITPHPPHP &gt;=8.0

Since Mar 31Pushed 1y ago1 watchersCompare

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

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

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

[](#laravel-api-response-package)

Introduction
------------

[](#introduction)

This package provides a standardized way to return JSON responses in Laravel applications. It simplifies response handling for success, validation, client errors, and server errors.

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

[](#installation)

Install the package via Composer:

```
composer require drdre4life2/api-response
```

Usage
-----

[](#usage)

### Include the Trait

[](#include-the-trait)

Add the `HasApiResponse` trait to your base `Controller`:

```
namespace App\Http\Controllers;

use Drdre4life2\ApiResponse\Traits\HasApiResponse;

abstract class Controller
{
    use HasApiResponse;

}
```

### Available Methods

[](#available-methods)

#### Success Responses

[](#success-responses)

```
return $this->okResponse('Success message', ['key' => 'value']);
return $this->createdResponse('Resource created', ['id' => 1]);
return $this->noContentResponse();
```

#### Client Error Responses

[](#client-error-responses)

```
return $this->badRequestResponse('Invalid request', ['error' => 'Details']);
return $this->unauthenticatedResponse('Unauthorized');
return $this->forbiddenResponse('Access denied');
return $this->notFoundResponse('Resource not found');
```

#### Server Error Responses

[](#server-error-responses)

```
return $this->serverErrorResponse('Server error occurred');
```

### Example in a Controller

[](#example-in-a-controller)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ExampleController extends Controller
{
    public function index(Request $request)
    {
        $data = ['message' => 'Hello, World!'];
        return $this->okResponse('Data retrieved successfully', $data);
    }
}
```

Testing
-------

[](#testing)

Run the test suite with:

```
php artisan test
```

License
-------

[](#license)

This package is open-source software licensed under the MIT License.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance46

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

407d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13998416?v=4)[Dare](/maintainers/drdre4life2)[@drdre4life2](https://github.com/drdre4life2)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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