tonybogdanov/memoize
Memoize caches the results of expensive function and method calls so repeated invocations return instantly. Simple attributes and helpers make it easy to add per-request or persistent memoization to Laravel and PHP apps, cutting duplicate queries and computation with minimal code changes.
spatie/once, or Laravel 11+'s native once() helper. That's a strategic decision about dependency surface area, not just a code-level choice.static properties and hand-rolled arrays — a maintainability and code-review-quality decision.Consider it when:
private ?array $cache boilerplate.Look elsewhere when:
once() helper covers the dominant use case with framework support and zero third-party risk — strongly prefer it unless this package offers something once() doesn't.For executives (one paragraph): This is a small, low-cost performance lever, not a platform investment. It lets engineers avoid recomputing the same expensive values multiple times within a single request — a common, invisible source of latency and database load. The upside is faster pages and fewer redundant queries at essentially zero infrastructure cost. The caveat is maturity: the package has negligible community adoption, so we should treat it as an evaluated tactic rather than a standard, and we may get the same benefit from Laravel's built-in once() helper with no third-party risk.
For engineering (summary): Object- and class-level in-memory memoization for PHP. It solves a real, narrow problem — repeated identical computation within a request — with no external dependencies. Before adopting: (1) confirm Laravel 11's once() doesn't already cover it; (2) audit the package source and pin the version; (3) explicitly test behavior under Octane/queue workers for stale state and memory growth; (4) agree on where memoization is allowed, since it's easy to introduce subtle staleness bugs; (5) add hit/miss instrumentation if we care about measuring the win. Recommendation: time-boxed spike on one hot path, measure query count and p95 latency, then decide between this, spatie/once, or native once().
How can I help you explore Laravel packages today?