pioniro/contextable-exception
Contextable exceptions for Laravel and PHP: throw exceptions that carry structured context data, so you can attach the values, inputs, or state behind a failure and read them back later when handling or logging it. Lightweight and simple to adopt.
order_id, tenant_id, payment_provider, or request payload fragments—so that logs and error trackers carry the information needed to diagnose a failure without reproducing it. As a PM, the decision this enables is: do we invest in diagnosability as a first-class quality attribute? This package is one small lever for that.Consider adopting (or borrowing the pattern) when:
PaymentDeclinedException, InventoryShortfallException) and want them to self-describe what went wrong and for whom, rather than pushing that responsibility into every catch block.Look elsewhere or avoid when:
context() method and the framework's logging stack already propagates it. The package is redundant.Recommended default: In most cases, the right move is to reimplement the idea internally—a HasContext interface plus a trait that merges context into getMessage()/log payloads—rather than taking the dependency. If you must take it, pin the version, vendor it, and own it.
For executives (one paragraph): This is a small, free, MIT-licensed utility that helps engineers capture what was happening when an error occurs—things like which customer, order, or transaction was involved—so problems get fixed faster and support tickets resolve in fewer round-trips. It is low-cost and low-risk in itself, but it is also unmaintained since 2020, so I do not recommend adding it as a formal production dependency. The recommendation is to adopt the pattern, not necessarily the package: it informs our observability and incident-response priorities, and the engineering time to replicate its value is minimal, while the governance risk of a dormant dependency is real.
For engineering leads: The package is a thin, single-purpose library for attaching structured context to exceptions so logs and error-trackers carry domain identifiers. Two caveats: it predates Laravel's native Exception::context() (Laravel 9+) and has had no release since April 2020 with no adopters. Recommend either (a) standardize on the framework's native context() if we're on Laravel 9+, (b) codify this as an internal convention with an interface + trait if we're on older versions, or (c) wire context directly through our error-tracker SDK. The product-facing outcome is the same—better diagnosability—but the dependency footprint and long-term ownership cost are lower with (a) or (b).
For product/QA stakeholders: Expect fewer "can't reproduce" bugs and faster triage. This is an engineering-quality investment, not a customer-visible feature, and it should be sequenced alongside our observability work rather than called out as a standalone deliverable.
How can I help you explore Laravel packages today?