Weave Code
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

Symbol Parser Laravel Package

composer-unused/symbol-parser

composer-unused/symbol-parser is a small toolkit that parses PHP symbols from a Composer package, helping tools like composer-unused detect what code is actually referenced. Useful for analyzing dependencies, exports, and usage across a project.

View on GitHub
Deep Wiki
Context7

Getting Started

This package is a low-level utility for extracting PHP symbols (classes, interfaces, traits, functions, constants) from installed Composer packages. Begin by installing it in a project via composer require --dev composer-unused/symbol-parser. Its primary entry point is the SymbolParser class — instantiate it and call parse() with a path to a Composer vendor directory or a specific package directory. The output is a structured array of symbol definitions, grouped by file and namespace. Its first use case is often inspecting which symbols a third-party package actually exposes, especially when auditing dependencies for unused code removal.

Implementation Patterns

Typical workflows involve integrating SymbolParser into build scripts or analysis tools. For example:

  • Integrate into a custom dependency audit tool (e.g., extending composer-unused/unused logic) to validate if a package's public API is actually used in code.
  • Preprocess package symbol maps for static analysis tools (like PHPStan or Psalm) to narrow scope or generate baseline rules.
  • In CI pipelines, compare parsed symbol lists against expected contracts or changelog entries to detect breaking changes in transitive dependencies.

The parser reads compiled Composer autoloader files (vendor/composer/autoload_psr4.php, autoload_classmap.php, etc.), then resolves files and extracts symbols using PHP Reflection or token parsing (e.g., token_get_all()), ensuring minimal runtime overhead.

Gotchas and Tips

  • No CLI tool: This is a library, not a standalone utility — you’ll need to write glue code (e.g., a Symfony Console command or Phing task) for manual exploration.
  • Autoloader dependency: It relies heavily on Composer’s autoloading metadata; if you use non-standard autoloading (e.g., manually included files outside vendor), parse results may be incomplete or inaccurate.
  • PHP version compatibility: The last release is dated 2026-01-29, likely indicating a future date — double-check whether it targets newer PHP versions (e.g., 8.2+). If targeting legacy code, test symbol extraction on older PHP tokens carefully.
  • Extension point: Implement custom SymbolResolver strategies to handle non-namespaced legacy code or parse polyfills and stubs. Also, consider caching parsed results to speed up iterative analysis.
  • Debugging tip: Enable verbose error reporting or inspect $parser->getStats() to catch files skipped due to syntax errors or unsupported constructs (e.g., PHP 8.1+ readonly properties may require updated token handling).
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope