Option
Model optional values without null checks scattered everywhere. Some/None with map, flatMap, filter and safe unwrapping.
Read Option
Option, Result, Schema and DTO for dependency-light PHP 7.4+ applications. Adopt one boundary at a time across Windows and legacy codebases.
composer require gabrielalmir/maybeInstall →use Maybe\Schema\Schema;
$result = Schema::shape([
'email' => Schema::string()->trimmed(),
])->safeParse($payload)
->andThen(fn (array $data) => saveCustomer($data));
$result->match(
fn (Customer $customer) => "Ok: saved",
fn (mixed $error) => "Err: fix input"
);No framework coupling, no rewrite. Validate input, model a fallible service, and decide what happens at the edge.
Install the core primitives
composer require gabrielalmir/maybeNew here? Read Why Maybe? for the trade-offs, follow the Tutorial to build a validated flow end to end, or keep the API Reference open while you work.