Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Contextable Exception Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The package addresses a narrow cross-cutting concern: attaching structured metadata (correlation ID, tenant, actor, job key) to exceptions so it survives to the handler and log sink. Architecturally this belongs in the application/domain layer as a small owned contract — an interface plus a trait — not as an external Composer dependency. The package's scope is small enough that it is effectively a specification rather than a library.

Integration feasibility. Low effort in principle: composer require, implement the interface/trait on selected exception classes, and read the context in App\Exceptions\Handler or a Monolog processor. No meaningful wiring or service provider complexity is expected. The realistic blocker is dependency resolution: a 2020-era composer.json is likely constrained to PHP 7.x and Laravel 5.5–6.x, which will conflict with PHP 8.2+/Laravel 10–11 and can block a framework upgrade outright.

Technical risk. High relative to delivered value.

  • Abandonment: no release since 2020-04-01, single maintainer, zero stars and zero dependents — no downstream users to surface bugs, no compatibility guarantees for PHP 8 JsonSerializable/signature behavior, no security disclosure channel.
  • Supply chain: the code executes on your error path, where a failure is most costly and least observable.
  • Blast radius: contained — it attaches read-only metadata — so a defect degrades observability rather than correctness, unless it throws during exception handling.
  • Policy: stale-dependency scanners will flag it perpetually, generating recurring governance noise for a component you could own in under two dev-days.

Key questions.

  1. What are the actual php, illuminate/*, and psr/log constraints — does it install cleanly on our target PHP/Laravel matrix?
  2. Does it include Laravel-specific rendering hooks (Ignition/Whoops) that would break on modern Ignition?
  3. What is the failure behavior when context contains non-serializable values (Eloquent models, PDO handles, closures) and the record is JSON-encoded?
  4. Does context survive rethrow/wrap via withPrevious(), or is it silently dropped?
  5. Are there tests, CI, or any maintenance signal in the repo history?
  6. Does Laravel's native Exception::context() (Laravel 9+) already cover the requirement, making the package redundant?

Integration Approach

Stack fit. PHP/Laravel. The concept fits any application emitting structured JSON logs to ELK, Datadog, or Sentry; it is orthogonal to framework version apart from handler wiring.

Migration path. Do not adopt as a runtime dependency. Port the interface and trait into app/Exceptions/Concerns/ or an internal platform/errors package under your own namespace — MIT permits this, retain the copyright notice. Preserve the upstream method names so the contract is unchanged and any future replacement is a one-line use swap. Modernize the fork: typed properties, array $context = [] constructor promotion, return types, PHPUnit/Pest coverage.

Compatibility. Validate against the PHP versions actually run in production. If consumed upstream, pin an exact version and add it to the dependency-policy allowlist with an explicit expiry review date.

Sequencing.

  1. Spike (≈½ day): install into a scratch Laravel app on the target matrix; either confirm install or capture the exact conflict for the record.
  2. Decision gate: fork/reimplement regardless of install success — the maintenance posture, not the install result, drives the call.
  3. Design the schema first: correlation_id, tenant_id, actor_id, route, job_id. This is the real work; the package contributes nothing here.
  4. Implement interface + trait; apply to the highest-value exception classes (payments, auth, third-party integrations) rather than blanket-applying.
  5. Wire the reader: Handler::context() on Laravel 9+ or a Monolog processor merging $e->getContext() into the record.
  6. Add an architecture test (PHPStan rule or Pest arch()) enforcing that new domain exceptions implement the contract.
  7. Ship behind structured logging and verify a synthetic exception reaches the sink with context intact before production rollout.

Operational Impact

Maintenance. Near-zero if forked (a few dozen lines); non-zero and unowned if consumed. Upstream has no release cadence, so every future PHP or Laravel major becomes an unpriced upgrade risk.

Support. No vendor, no community — zero dependents means effectively no users to answer questions. Internal code ownership is mandatory; assign a named owner for the ported copy.

Scaling. No runtime scaling concern; this is in-memory metadata on the error path only. The real scaling variable is log volume: context must be size-capped and whitelisted, or you inflate log storage cost and ingestion latency.

Failure modes.

  • Serialization failure on non-JSON-safe context values throwing inside the exception handler and masking the original error — mitigate with a sanitizer before logging.
  • PII leakage (emails, tokens, payload fragments) into third-party log aggregators.
  • Silent context loss when exceptions are wrapped without merging previous.
  • Composer resolution breaking a framework upgrade — the classic "stale transitive dependency blocks PHP 8" scenario.
  • Signature drift between the fork and any future upstream revival.

Ramp-up. Very low for engineers: under an hour to understand, one to two dev-days total for fork, tests, wiring, and rollout. The genuine ramp-up cost is documenting the context schema and the handler contract — not the library.

Bottom line. The capability is worth having; this package is not worth depending on. Treat the repository as a specification, vendor the pattern under MIT terms, and own the interface. Cost to replicate is under two dev-days against a maintenance risk that will materialize at your next major upgrade.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package