PHPackages                             sardar-backend/lara-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. sardar-backend/lara-response

ActiveLibrary[API Development](/categories/api)

sardar-backend/lara-response
============================

A Laravel package for API response handling

215PHP

Since Apr 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SardarBackend/LaraResponse)[ Packagist](https://packagist.org/packages/sardar-backend/lara-response)[ RSS](/packages/sardar-backend-lara-response/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Restful API Response Package
============================

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

[![Packagist Version](https://camo.githubusercontent.com/76f7ef72af03ce401e190351a19eccf23f6704e07e51cd303a5aac34faef2100/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361726461726261636b656e642f4c617261526573706f6e7365)](https://camo.githubusercontent.com/76f7ef72af03ce401e190351a19eccf23f6704e07e51cd303a5aac34faef2100/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7361726461726261636b656e642f4c617261526573706f6e7365)[![License](https://camo.githubusercontent.com/198ffe9f48c7492ec15a65fe7c25480792efff406b0bde1bb20f6275d6037d4f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7361726461726261636b656e642f4c617261526573706f6e7365)](https://camo.githubusercontent.com/198ffe9f48c7492ec15a65fe7c25480792efff406b0bde1bb20f6275d6037d4f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7361726461726261636b656e642f4c617261526573706f6e7365)

A robust and customizable API response helper for Laravel applications, designed to simplify JSON responses and maintain consistency across your API.

📌 Features
----------

[](#-features)

- Standardized API response structure
- Effortless HTTP status code management
- Append additional metadata seamlessly
- Fluent and intuitive interface
- Fully compatible with Laravel's response system

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require sardar-backend/lara-response:dev-master
```

🚀 Usage
-------

[](#-usage)

### 1️⃣ Generate the Service Class

[](#1️⃣-generate-the-service-class)

First, create a new service class using the following command:

```
php artisan make:service ModelName
```

To properly inject `ProductServices` into your controller, use the constructor method:

```
public function __construct(private ProductServices $productServices) {
}
```

### Basic Example

[](#basic-example)

```
use SardarBackend\RestfulApiHelper\RestfulApi\Fecades\ApiResponseFacade;

$result = $this->productServices->getAll($request->all());

if (!$result->ok) {
    return ApiResponseFacade::withMessage($result->data)->withStatus(500)->build()->Response();
}
return ApiResponseFacade::withData(ApiProductListResource::collection($result->data)->resource)->build()->Response();
```

### Adding Additional Data

[](#adding-additional-data)

```
use SardarBackend\RestfulApiHelper\RestfulApi\Fecades\ApiResponseFacade;

$result = $this->productServices->getAll($request->all());

if (!$result->ok) {
    return ApiResponseFacade::withMessage($result->data)->withStatus(500)->build()->Response();
}
return ApiResponseFacade::withData(ApiProductListResource::collection($result->data)->resource)->withAppends(['processing_time' => '2 seconds'])->build()->Response();
```

🛠 Methods
---------

[](#-methods)

MethodDescription`withMessage(string $message)`Sets the response message`withData(mixed $data)`Sets the response data`withStatus(int $status)`Sets the HTTP status code`withAppends(array $appends)`Adds additional key-value pairs to the response`response()`Returns a Laravel `JsonResponse` object📜 License
---------

[](#-license)

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

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Feel free to submit issues or pull requests on [GitHub](https://github.com/SardarBackend/LaraResponse).

📬 Contact
---------

[](#-contact)

For any inquiries, reach out via [GitHub Issues](https://github.com/SardarBackend/LaraResponse/issues).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b38e776d2b106f7e15acdbb45299082b4bf7fd4f41e53e30355d3769e935fb1?d=identicon)[Sardar-backend](/maintainers/Sardar-backend)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/sardar-backend-lara-response/health.svg)

```
[![Health](https://phpackages.com/badges/sardar-backend-lara-response/health.svg)](https://phpackages.com/packages/sardar-backend-lara-response)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.5M7](/packages/exsyst-swagger)[lucasdotvin/laravel-soulbscription

A straightforward interface to handle subscriptions and features consumption.

709209.3k](/packages/lucasdotvin-laravel-soulbscription)[pimax/fb-messenger-php

Facebook Messenger Bot PHP API

313188.5k2](/packages/pimax-fb-messenger-php)

PHPackages © 2026

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