spatie/sourcemaps-lookup
Fast, memory-efficient Source Map v3 lookup for PHP. Resolve JavaScript stack frames to original source file, line/column, symbol name, and enclosing scope. Optimized for the read path and high-volume error symbolicating from uploaded sourcemaps.
axy/sourcemap) are slower or memory-inefficient.lookup()).scopeAt()) to match browser devtools.debugbar).ignoreList-marked sources.Adopt if:
scopes when bundlers support it.Look elsewhere if:
sourcesContent is supported).source-map support).For Executives:
"This package lets us automatically resolve minified JavaScript errors back to their original source files in PHP, just like Chrome DevTools does for frontend developers. For example, if a user reports an error in our React app, we can now show them the exact line in their original App.tsx—not just a minified bundle.js:42:17. This directly improves debugging velocity for our frontend team and user support quality, while keeping the heavy lifting in PHP (no Node.js dependencies). Benchmarks show it handles 6MB source maps in ~4ms, making it viable for production error tracking at scale. The MIT license and Spatie’s track record mean low risk."
For Engineering:
*"This is a drop-in replacement for axy/sourcemap but optimized for PHP’s strengths:
scopeAt()) to identify enclosing functions/classes, matching browser devtools.ignoreList, sourceRoot, and null sources correctly.
Use case: Plug this into your error handler (e.g., Sentry, Laravel’s debugbar) to replace eval()-based source maps or manual regex hacks. Example:$map = SourceMapLookup::fromFile(storage_path('bundle.js.map'));
$position = $map->lookup($errorLine, $errorColumn);
$context = $map->sourceLines($position->sourceFileIndex, $position->sourceLine - 5, $position->sourceLine + 5);
Tradeoff: No write/merge support, but that’s intentional—this is the fastest read-only v3 parser for PHP."*
How can I help you explore Laravel packages today?