PHPackages                             aphonix/option - 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. aphonix/option

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

aphonix/option
==============

A zero-dependency, type-safe implementation of Rust's Option type for PHP 7.1+. Handle optional values with elegance.

v1.0.1(1mo ago)2199[1 PRs](https://github.com/aphonix/option/pulls)MITPHPPHP &gt;=7.1

Since Jan 7Pushed 1mo ago1 watchersCompare

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

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

**🦀 Rust-style Option for PHP 🐘**
=================================

[](#-rust-style-option-for-php-)

A lightweight, zero-dependency implementation of Rust's Option for PHP 7.1+. This library brings functional programming patterns to PHP, helping you handle optional values explicitly and write more expressive code.

**✨ Features**
--------------

[](#-features)

- **PHP 7.1+ Compatibility**: Fully supports all versions from PHP 7.1 up to PHP 8.4+.
- **Strict Rust API**: Ported core methods from the Rust Standard Library (std::option).
- **Singleton None**: Memory-efficient implementation using a singleton for the None type.
- **Global Helper Functions**: Idiomatic Some() and None() functions for a clean development experience.
- **Explicit Optional Values**: Encourages callers to handle values that may be absent instead of relying on implicit null checks.

**🚀 Installation**
------------------

[](#-installation)

You can install the package via [Composer](https://getcomposer.org/):

```
composer require aphonix/option
```

**📖 Quick Start**
-----------------

[](#-quick-start)

### **Basic Usage**

[](#basic-usage)

```
