PHPackages                             ferdous-ahmed-khan/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. ferdous-ahmed-khan/laravel-api-response

ActiveLibrary[API Development](/categories/api)

ferdous-ahmed-khan/laravel-api-response
=======================================

A Laravel package providing standardized JSON response helpers for success and error handling, with functions for quick, consistent API responses.

v1.0.1(1y ago)115MITPHP

Since Nov 8Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

API Response Package Installation Guide
=======================================

[](#api-response-package-installation-guide)

This guide will walk you through the installation and setup process for integrating the package into your Laravel project.

### JSON Response Structure

[](#json-response-structure)

```
{
   "status": true|false,
   "message": "Your message here",
   "data": { /*optional data */ },
   "errors": { /* optional error details*/ }
}
```

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

[](#requirements)

- Laravel 8.x or higher
- PHP 7.4+ (or higher, depending on the package requirements)
- Composer

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

[](#installation)

To install the package, follow these steps:

### 1. Install via Composer

[](#1-install-via-composer)

Run the following command in your Laravel project root directory to install the package:

```
composer require ferdous-ahmed-khan/laravel-api-response
```

### 2. Open config/app.php

[](#2-open-configappphp)

In the providers array, add the following line to register the service provider:

```
'providers' => [
    // Other Service Providers...

    FerdousAhmedKhan\LaravelApiResponse\ResponseHelperServiceProvider::class,
],
```

In the aliases array, add the following line to create an alias for the ResponseHelper facade:

```
'aliases' => [
    // Other Aliases...

    'ApiResponse' => FerdousAhmedKhan\LaravelApiResponse\ResponseHelperFacade::class,
],
```

### 3. Usage

[](#3-usage)

Once the package is installed, you can start using its features. For example, to use the

```
use ApiResponse;
```

### `success()`

[](#success)

Generates a successful response with HTTP status `200`.

```
return ApiResponse::success('Operation successful', $data);
```

### `deleted()`

[](#deleted)

Generates a response for successful deletions with HTTP status `200`

```
return ApiResponse::deleted('Record deleted successfully', $data);
```

### `created()`

[](#created)

Generates a response for successful creation with HTTP status `201`

```
return ApiResponse::created('Resource created successfully', $data);
```

### `badRequest()`

[](#badrequest)

Generates a response for a bad request with HTTP status `400`.

```
return ApiResponse::badRequest('Invalid request data', $errorDetails);
```

### `failed()`

[](#failed)

Generates a generic failure response with HTTP status `400`.

```
return ApiResponse::failed('Operation failed', $errorDetails);
```

### `unauthorized()`

[](#unauthorized)

Generates a response for forbidden access with HTTP status `403`.

```
return ApiResponse::forbidden('Access is forbidden', $errorDetails);
```

### `forbidden()`

[](#forbidden)

Generates a response for forbidden access with HTTP status `403`.

```
return ApiResponse::forbidden('Access is forbidden', $errorDetails);
```

### `notFound()`

[](#notfound)

Generates a response for resources not found with HTTP status `404`.

```
return ApiResponse::notFound('Resource not found', $errorDetails);
```

### `validationFailed()`

[](#validationfailed)

Generates a response for validation failure with HTTP status `422`.

```
return ApiResponse::validationFailed('Validation failed', $validationErrors);
```

### `internalServerError()`

[](#internalservererror)

Generates a response for server errors with HTTP status `500`.

```
return ApiResponse::internalServerError('An error occurred', $errorDetails);
```

### `custom()`

[](#custom)

Generates a custom response with a specified HTTP status code.

```
return ApiResponse::custom(true, 202, 'Request accepted', $data, null);
```

Each function returns a JsonResponse object with a consistent structure:

```
{
   "status": true|false,
   "message": "Your message here",
   "data": { /*optional data */ },
   "errors": { /* optional error details*/ }
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

551d ago

### Community

Maintainers

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

---

Top Contributors

[![ferdous-ahmed-khan](https://avatars.githubusercontent.com/u/49646484?v=4)](https://github.com/ferdous-ahmed-khan "ferdous-ahmed-khan (6 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/ferdous-ahmed-khan-laravel-api-response/health.svg)](https://phpackages.com/packages/ferdous-ahmed-khan-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)
