PHPackages                             romuloar/rom.result - 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. romuloar/rom.result

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

romuloar/rom.result
===================

A PHP library for encapsulating method results, inspired by the .NET package rom.result. Provides standardized Success, Error, Warning, and Info result objects with sync and async (Closure) APIs.

01PHP

Since May 27Pushed 11mo agoCompare

[ Source](https://github.com/romuloar/rom.result-php)[ Packagist](https://packagist.org/packages/romuloar/rom.result)[ RSS](/packages/romuloar-romresult/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Rom.Result PHP
==============

[](#romresult-php)

A PHP library for encapsulating method results, inspired by the .NET package [rom.result](https://github.com/romuloar/rom.result). It provides a standardized way to return operation results with status, messages, data, and errors, supporting both synchronous and simulated asynchronous (Closure) APIs.

Features
--------

[](#features)

- Standardized result objects for Success, Error, Warning, and Info
- Rich result details: type, message, data, errors
- Extension methods for easy creation of results
- Synchronous and simulated asynchronous (Closure) APIs
- 100% unit tested
- Easy integration with any PHP project

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

[](#installation)

```
composer require romuloar/rom.result
```

Quick Start
-----------

[](#quick-start)

### Creating Results

[](#creating-results)

#### Success

[](#success)

```
use Rom\Result\Extensions\SuccessExtensions;

// Synchronous
$result = SuccessExtensions::getResultDetailSuccess('Operation succeeded', ['id' => 1]);
$resultWithData = SuccessExtensions::getResultDetailSuccessWithData(['id' => 1]);
$resultOnlyMessage = SuccessExtensions::getResultDetailSuccessMessage('Just a message');

// Asynchronous (simulated)
$resultAsync = SuccessExtensions::getResultDetailSuccessAsync('Async success', ['id' => 1]);
$actualResult = $resultAsync(); // Call closure to get ResultDetail
```

#### Error

[](#error)

```
use Rom\Result\Extensions\ErrorExtensions;

$result = ErrorExtensions::getResultDetailError('Operation failed', null, ['code' => 500]);
$resultWithData = ErrorExtensions::getResultDetailErrorWithData('Failed with data', ['id' => 1]);
$resultOnlyMessage = ErrorExtensions::getResultDetailErrorMessage('Just a message');
$resultWithDataOnly = ErrorExtensions::getResultDetailErrorWithDataOnly(['id' => 1]);

// Asynchronous (simulated)
$resultAsync = ErrorExtensions::getResultDetailErrorAsync('Async error', null, ['code' => 500]);
$actualResult = $resultAsync();
```

#### Warning

[](#warning)

```
use Rom\Result\Extensions\WarningExtensions;

$result = WarningExtensions::getResultDetailWarning('Be careful!', ['field' => 'email']);
$resultWithData = WarningExtensions::getResultDetailWarningWithData(['field' => 'email']);
$resultOnlyMessage = WarningExtensions::getResultDetailWarningMessage('Just a warning');

// Asynchronous (simulated)
$resultAsync = WarningExtensions::getResultDetailWarningAsync('Async warning', ['field' => 'email']);
$actualResult = $resultAsync();
```

#### Info

[](#info)

```
use Rom\Result\Extensions\InfoExtensions;

$result = InfoExtensions::getResultDetailInfo('Just FYI', ['step' => 2]);
$resultWithData = InfoExtensions::getResultDetailInfoWithData(['step' => 2]);
$resultOnlyMessage = InfoExtensions::getResultDetailInfoMessage('Just info');

// Asynchronous (simulated)
$resultAsync = InfoExtensions::getResultDetailInfoAsync('Async info', ['step' => 2]);
$actualResult = $resultAsync();
```

### Checking Result Types

[](#checking-result-types)

```
use Rom\Result\Extensions\ResultDetailExtensions;

if (ResultDetailExtensions::getResultDetailIsSuccess($result)) {
    // handle success
}
if (ResultDetailExtensions::getResultDetailIsError($result)) {
    // handle error
}
if (ResultDetailExtensions::getResultDetailIsWarning($result)) {
    // handle warning
}
if (ResultDetailExtensions::getResultDetailIsInfo($result)) {
    // handle info
}

// Asynchronous (simulated)
$checkAsync = ResultDetailExtensions::getResultDetailIsSuccessAsync($result);
if ($checkAsync()) {
    // handle async success
}
```

### Accessing Result Details

[](#accessing-result-details)

```
use Rom\Result\Helpers\ResultDetailHelper;

$message = ResultDetailHelper::getMessage($result);
$data = ResultDetailHelper::getData($result);
$errors = ResultDetailHelper::getErrors($result);
```

### Using the Factory

[](#using-the-factory)

```
use Rom\Result\Factories\ResultDetailFactory;
use Rom\Result\Domain\ResultType;

$result = ResultDetailFactory::create(ResultType::Success, 'Created', ['id' => 1]);
```

ResultDetail Structure
----------------------

[](#resultdetail-structure)

```
ResultDetail {
    ResultType $type; // Success, Error, Warning, Info
    string $message;
    mixed $data;
    ?array $errors;
}
```

Advanced Usage
--------------

[](#advanced-usage)

- You can extend or wrap the result pattern for your own domain needs.
- Combine with service layers to standardize all method returns.
- Use the async (Closure) pattern to integrate with event loops or promise libraries if needed.

Testing
-------

[](#testing)

Run all tests with PHPUnit:

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

License
-------

[](#license)

MIT

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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/0cef3de36e5e4864aac8475082041920dcdd31465ce8b2b0ece1a24ba696b589?d=identicon)[romuloar](/maintainers/romuloar)

---

Top Contributors

[![romuloar](https://avatars.githubusercontent.com/u/9424233?v=4)](https://github.com/romuloar "romuloar (1 commits)")

### Embed Badge

![Health badge](/badges/romuloar-romresult/health.svg)

```
[![Health](https://phpackages.com/badges/romuloar-romresult/health.svg)](https://phpackages.com/packages/romuloar-romresult)
```

PHPackages © 2026

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