PHPackages                             manhhuyvo/action-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. manhhuyvo/action-response

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

manhhuyvo/action-response
=========================

A fluent, structured PHP action response class which supports messages, errors, and data.

v1.0.1(5mo ago)14PHPPHP &gt;=8.1

Since Dec 6Pushed 5mo agoCompare

[ Source](https://github.com/manhhuyvo/action-response)[ Packagist](https://packagist.org/packages/manhhuyvo/action-response)[ RSS](/packages/manhhuyvo-action-response/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

ActionResponse
==============

[](#actionresponse)

A lightweight and expressive response helper designed to provide a consistent structure when returning action results in PHP applications.

This package includes:

- A `Response` class with a fluent API
- A `ResponseStatus` enum (`success`, `error`, `snooze`)
- Convenience constructors (`success()`, `error()`, `snooze()`)
- Helpers for attaching messages, errors, data, and retrieving nested data via dot notation

---

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

[](#-installation)

Install via Composer:

```
composer require manhhuyvo/action-response
```

---

🚀 Basic Usage
-------------

[](#-basic-usage)

### Create a **success** response

[](#create-a-success-response)

```
use ManhHuyVo\ActionResponse\Response;

$response = Response::success()
    ->message('Action completed successfully.')
    ->data(['foo' => 'bar']);

return $response;
```

### Create an **error** response

[](#create-an-error-response)

```
$response = Response::error()
    ->message('Unable to process request.')
    ->errors(['Invalid input', 'Another error']);

return $response;
```

### Create a **snooze** response

[](#create-a-snooze-response)

Useful when the action should be skipped or is not applicable.

```
$response = Response::snooze()
    ->message('Skipping this action for now.');

return $response;
```

---

🧱 Response Structure
--------------------

[](#-response-structure)

A `Response` object contains:

PropertyTypeDescription`status`stringOne of `success`, `error`, `snooze``message`stringOptional explanation`errors`arrayUnique list of errors (duplicates removed automatically)`data`arrayOptional payloadExample structure:

```
[
    'status' => 'success',
    'message' => 'Action completed successfully.',
    'errors' => [],
    'data' => [
        'foo' => 'bar'
    ],
]
```

---

🔍 Status Checking
-----------------

[](#-status-checking)

```
$response->isSuccessful(); // true / false
$response->isError();      // true / false
$response->isSnooze();     // true / false
```

---

🎯 Setting Values Manually
-------------------------

[](#-setting-values-manually)

```
$response = (new Response())
    ->status('success')
    ->message('Done')
    ->data(['x' => 1])
    ->errors([]);

return $response;
```

---

📥 Accessing Nested Data (Dot Notation)
--------------------------------------

[](#-accessing-nested-data-dot-notation)

If your data is nested:

```
$response = Response::success()->data([
    'user' => [
        'profile' => [
            'email' => 'john@example.com'
        ],
    ],
]);
```

You can fetch nested values:

```
$response->getData('user.profile.email');

// "john@example.com"
```

---

🧩 ResponseStatus Enum
---------------------

[](#-responsestatus-enum)

```
enum ResponseStatus: string
{
    case Success = 'success';
    case Error   = 'error';
    case Snooze  = 'snooze';
}
```

---

🧪 Running Tests
---------------

[](#-running-tests)

If you are developing locally, run PHPUnit:

```
vendor/bin/phpunit --testdox
```

---

📚 Example Usage in a Real Action
--------------------------------

[](#-example-usage-in-a-real-action)

```
use ManhHuyVo\ActionResponse\Response;

function processOrder(array $order): Response
{
    if (empty($order)) {
        return Response::error()
            ->message('Order cannot be empty.')
            ->errors(['order_empty']);
    }

    if ($order['status'] === 'skipped') {
        return Response::snooze()
            ->message('Order skipped.');
    }

    return Response::success()
        ->message('Order processed.')
        ->data(['id' => 123]);
}
```

---

📝 License
---------

[](#-license)

MIT License.

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance77

Regular maintenance activity

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 58.3% 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 ~0 days

Total

2

Last Release

154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e9b039fddbf4a65666e8140bb05929d84b0ae79a5c600b491e35c41d28fd2cb?d=identicon)[manhhuyvo](/maintainers/manhhuyvo)

---

Top Contributors

[![manhhuyvo](https://avatars.githubusercontent.com/u/41469641?v=4)](https://github.com/manhhuyvo "manhhuyvo (14 commits)")[![manhhuyvo-coding](https://avatars.githubusercontent.com/u/171243545?v=4)](https://github.com/manhhuyvo-coding "manhhuyvo-coding (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/manhhuyvo-action-response/health.svg)

```
[![Health](https://phpackages.com/badges/manhhuyvo-action-response/health.svg)](https://phpackages.com/packages/manhhuyvo-action-response)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M681](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M856](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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