finds.dev← search

// the find

GrahamCampbell/Result-Type

★ 554 · PHP · MIT · updated May 2026

An implementation of the result type

A minimal PHP implementation of the Result type — Success and Error variants wrapping a value — borrowed from functional languages like Rust and Haskell. Useful for PHP code that wants to make failure explicit in the return type instead of throwing exceptions or returning nulls. At 554 stars and 3 source files, this is about as small as a library gets.

Covers PHP 7.2 through 8.5, so it works in legacy codebases that can't adopt newer type features yet. The API is exactly what you'd expect: `Success::create($value)`, `$result->success()`, `$result->failure()` — no ceremony. Being a single-maintainer package from Graham Campbell means it actually gets maintained; the changelog shows consistent upkeep. Packagist downloads indicate real adoption despite the low fork count.

No monadic chaining — there's no `map()`, `flatMap()`, or `andThen()`, which means you're back to writing `if ($result->success())` branches everywhere, which is barely better than the exceptions you were avoiding. The library predates PHP 8.0 union types and 8.1 enums, and hasn't evolved to use them — a modern implementation would use an enum-backed sealed type. With only 3 source files, most teams would be better off writing their own Result type so they can shape the API to their needs. The README is nearly empty; anyone unfamiliar with the pattern has to figure it out from the source.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →