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

ActiveLibrary

ba0918/result
=============

Rust-inspired Result and Option types for PHP, with immutable design and full type safety

v1.0.0(today)02↑2900%MITPHPPHP ^8.3CI passing

Since Aug 14Pushed todayCompare

[ Source](https://github.com/ba0918/result)[ Packagist](https://packagist.org/packages/ba0918/result)[ RSS](/packages/ba0918-result/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

PHP Result/Option Library
=========================

[](#php-resultoption-library)

[![PHP Version](https://camo.githubusercontent.com/e69fc10ad0d3845d44d08b0eeedd6dd7a5bfa4ab872e68e26b131554122d35d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c75652e737667)](https://camo.githubusercontent.com/e69fc10ad0d3845d44d08b0eeedd6dd7a5bfa4ab872e68e26b131554122d35d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c75652e737667)[![PHPStan](https://camo.githubusercontent.com/e6bc32c300a7a93b35a137a618eff5bcc149a3406fcabdc71e85527d3dbbaebb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d41582d627269676874677265656e2e737667)](https://camo.githubusercontent.com/e6bc32c300a7a93b35a137a618eff5bcc149a3406fcabdc71e85527d3dbbaebb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d41582d627269676874677265656e2e737667)[![Tests](https://github.com/ba0918/result/actions/workflows/quality-check.yml/badge.svg)](https://github.com/ba0918/result/actions/workflows/quality-check.yml/badge.svg)[![Coverage](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)

[日本語](README.ja.md)

A PHP implementation of Rust's Result and Option types for robust error handling and null safety.

Features
--------

[](#features)

- **Type-safe error handling** - express success/failure explicitly instead of using exceptions or null
- **Functional programming** - declarative code through method chaining
- **Rust compatible** - 97% specification compliance with the Rust standard library
- **High quality** - PHPStan Level MAX, 100% test coverage

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Quick Start](#quick-start)
3. [Documentation](#documentation)
4. [Key Features](#key-features)
5. [Requirements](#requirements)
6. [Development](#development)
7. [License](#license)

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

[](#installation)

```
composer require ba0918/result
```

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

[](#quick-start)

### Result Type - Error Handling

[](#result-type---error-handling)

```
