PHPackages                             ars/api-responder-laravel - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ars/api-responder-laravel

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ars/api-responder-laravel
=========================

A library to simplify the creation of standardized API responses.

v1.0.8(1y ago)12501MITPHPPHP &gt;=8.0

Since Aug 15Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (10)Used By (0)

API Responder - Laravel Response
================================

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

**ars/api-responder-laravel** is a Laravel package designed to streamline the creation of standardized API responses. It provides a user-friendly interface for managing API responses, including common status codes and error messages, making API development in Laravel more efficient and consistent.

Features
--------

[](#features)

- Standardized response structure for successful and error responses.
- Customizable response data with support for links and metadata.
- Easy integration with Laravel through a facade and service provider.

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

[](#installation)

You can install the library via Composer. Run the following command:

```
composer require ars/api-responder-laravel
```

Usage
=====

[](#usage)

Basic Response
--------------

[](#basic-response)

You can use the Responder facade to create standardized API responses.

### Example:

[](#example)

```
use Responder;

return Responder::ok($response);
return Responder::setMessage('success')->ok($response);
return Responder::tooManyRequests();
return Responder::notFound();
return Responder::unAuthorized();

$data = $this->repository->paginate();
$links = [
    'next' => $data->nextPageUrl(),
    'prev' => $data->previousPageUrl(),
    'path' => $data->path(),
];
$meta = [
    'total'        => $data->total(),
    'current_page' => $data->currentPage(),
    'per_page'     => $data->perPage(),
];
return Responder::setMeta($meta)->setLinks($links)->ok($data->items());

return Responder::setStatusCode(500)->setMessage($e->getMessage())->respond();
```

```
{
  "message": "Operation successful!",
  "success": true,
  "data": {
    "accessToken": "28|PDVEA7z6mUPcbbIybkpiMPJMvy3TLtuWOguiGDGn13c67491",
    "tokenType": "Bearer",
    "expiresIn": null
  }
}
```

Additional Methods
------------------

[](#additional-methods)

- `ok(array $data)`: Return a response 200.
- `respond(array $data)`: Prepare and return a response.
- `setData(array $data)`: Set the response data.
- `setMessage(string $message)`: Set a message for the response.
- `appendData(array $data)`: Append additional data to the response.
- `setErrorCode(mixed $errorCode)`: Set an error code for the response.
- `setStatusCode(int $statusCode)`: Set the HTTP status code for the response.
- `setLinks(array $links)`: Set pagination or other links.
- `setMeta(array $meta)`: Set metadata for the response.

Messages
--------

[](#messages)

The library supports various status messages:

#### If a message key is provided, use `setMessage(string $message)` to set the message.

[](#if-a-message-key-is-provided-use-setmessagestring-message-to-set-the-message)

- **success:** "Operation successful!"
- **error:** "Operation encountered an error!"
- **validation\_error:** "Validation failed!"
- **internal\_error:** "Internal server error!"
- **created:** "has been created."
- **updated:** "has been updated."
- **deleted:** "has been deleted."
- **send:** "has been sent."
- **before\_posted:** "has already been posted."
- **expire:** "has expired."
- **not\_valid:** "is not valid."
- **used:** "has already been used."
- **re\_send:** "has been resent."
- **unauthenticated:** "User is not authenticated!"
- **unauthorized:** "User is not authorized to access this resource!"
- **not\_found:** "Resource not found!"
- **bad\_request:** "Bad request!"
- **to\_many\_request:** "Too many requests!"

Contributing
------------

[](#contributing)

Contributions are welcome! Please adhere to the following guidelines:

1. Fork the repository.
2. Create a feature branch (git checkout -b feature/my-new-feature).
3. Commit your changes (git commit -am 'Add new feature').
4. Push to the branch (git push origin feature/my-new-feature).
5. Open a Pull Request.

License
-------

[](#license)

This library is licensed under the MIT License.

Contact
-------

[](#contact)

For support or questions, please open an issue on GitHub.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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 ~7 days

Total

9

Last Release

574d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06fa4d332d575f1bcee0f091115409cbae2070d1b519e4e0e44f00ee7fc58c6e?d=identicon)[alireza2000sajedi](/maintainers/alireza2000sajedi)

---

Top Contributors

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

---

Tags

httpresponsephpjsonapilaravelrestresponderapi-responderstandardizedLaravel Responder

### Embed Badge

![Health badge](/badges/ars-api-responder-laravel/health.svg)

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

###  Alternatives

[givebutter/laravel-keyable

Add API keys to your Laravel models

187144.5k2](/packages/givebutter-laravel-keyable)[guanguans/laravel-api-response

Normalize and standardize Laravel API response data structure. - 规范化和标准化 Laravel API 响应数据结构。

485.6k](/packages/guanguans-laravel-api-response)

PHPackages © 2026

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