spatie/backtrace
Spatie Backtrace provides a cleaner, easier-to-use alternative to PHP’s debug_backtrace. It returns a structured list of Frame objects with accurate file, line, class/method info, and optional arguments, making traces simpler to inspect and filter.
Debugging & Observability:
Roadmap Priorities:
withArguments() and reduceArguments() to analyze slow endpoints by inspecting function arguments in production-like environments.Use Cases:
DateTime formatting, sensitive data masking).applicationPath() + trimFilePaths()).artisan/please as vendor frames (avoids false positives).startingFromFrame() to skip framework noise in unit/integration tests (e.g., focus on user code).getSnippetAsString()) for documentation or IDE plugins.Adopt if:
debug_backtrace() output.artisan/please misclassified as application code).offset(), limit()).Look elsewhere if:
debug_backtrace() suffices (minimal overhead).backtrace_locations).withoutArguments() to optimize).*"This package transforms how we debug and monitor errors in PHP/Laravel. By replacing raw backtraces with structured, filtered, and human-readable data, we can:
*"Problem: Raw debug_backtrace() is clunky—skewed function names, no arguments/objects, and vendor noise clutters logs.
Solution: spatie/backtrace gives us:
Frame objects with file, lineNumber, arguments, object, etc.—no bitmask hell.artisan/please as vendor frames (Laravel/Statamic support).DateTime) for logs.withoutArguments() if needed).
Next Steps: Add to composer.json and integrate with our error handler/Sentry client. Example:$backtrace = Backtrace::create()
->applicationPath(base_path())
->withArguments()
->reduceArguments()
->frames();
```*
**Ask**: Should we prioritize this for the next debugging sprint?"*
How can I help you explore Laravel packages today?