symplify/simple-php-doc-parser
Simple PHP Doc Parser by Symplify is a lightweight library for reading PHP docblocks. It extracts comments, tags, and annotations from classes, methods, and properties through a simple API, making PHPDoc data easy to use in static analysis, code generation, and documentation tools.
Architecture fit. symplify/simple-php-doc-parser is a thin service wrapper around phpstan/phpdoc-parser, the AST-based docblock parser maintained by PHPStan. It exposes a SimplePhpDocParser with convenience methods that return parsed docblock nodes, sparing callers from wiring up lexers, token iterators, and PhpDocParser configuration themselves. For a Laravel application, the package is framework-agnostic and has no Laravel-specific coupling — it is a plain PHP library that can be resolved from the container. Architecturally, it fits only where you actually need structured PHPDoc introspection: code generation, static analysis tooling, annotation-driven metadata, IDE-helper artifact generation, or tooling that maps docblocks to runtime/discovery metadata. It does not belong in request-path business logic.
Integration feasibility. High mechanically: composer require symplify/simple-php-doc-parser, bind SimplePhpDocParser as a singleton in a service provider, inject where needed. No configuration files, no publishable assets, no service provider shipped by the package. The real friction is version alignment: the wrapper pins a compatible range of phpstan/phpdoc-parser, and you may already have phpstan/phpdoc-parser (directly or transitively via PHPStan, Rector, Larastan, or Psalm bridges) at a version the wrapper does not accept. That is the most likely integration blocker and should be validated with composer why phpstan/phpdoc-parser before committing.
Technical risk.
Lexer + PhpDocParser + ConstExprParser + TypeParser directly — is roughly 30–50 lines. Migration cost is low, which cuts both ways: low switching cost for you, but also low defensibility for the package.phpstan/phpdoc-parser; a major upstream bump (v1 → v2 changed constructor signatures and node handling) can strand the wrapper.Key questions.
phpstan/phpdoc-parser constraint does the wrapper declare, and does it intersect with versions already in the lockfile?phpstan/phpdoc-parser directly and own a small internal adapter?Stack fit. Clean. No Laravel version constraints, no facade or config expectations, PSR-4 autoloading only. Works identically on Laravel 9–12 and on PHP 8.1+ assuming composer resolution succeeds. It is tooling-adjacent rather than application-runtime, so it should sit in require-dev unless a production feature genuinely parses docblocks at runtime.
Migration path. Two viable routes:
DocBlockReader with properties(), methods(), tags()), implement it with the wrapper today, and keep the implementation behind the container binding. Swapping to raw phpstan/phpdoc-parser or a future fork then becomes a one-class change.If adoption is exploratory, installing into require-dev and prototyping inside a single Artisan command is a cheap way to validate the value before formalizing.
Compatibility. Verify against the existing lockfile first: composer require symplify/simple-php-doc-parser --dry-run. Watch for conflicts with Larastan/PHPStan (which ships phpstan/phpdoc-parser), Rector, and any Psalm bridge. Because the wrapper is not on a fast release cadence, expect its upstream constraint to lag; if the project already runs a recent phpstan/phpdoc-parser, resolution may fail outright.
Sequencing.
Maintenance. Low ongoing effort from you, but effectively zero upstream maintenance. Treat the dependency as frozen: no automatic composer update for this package, Dependabot/Renovate configured for notification-only, and a documented decision record noting the deprecation risk. The internal adapter is the real maintenance asset; the package is a disposable implementation detail.
Support. No vendor support, no SLA, community-only via GitHub issues on a low-traffic repository. Internal support means one or two engineers who understand PHPDoc ASTs. Budget for that as a knowledge silo and document the parsing entry points.
Scaling. Negligible runtime footprint — parsing is CPU-bound, in-memory, and microseconds-to-low-milliseconds per docblock. It does not scale with request volume in any meaningful way. It scales with file count: if you parse every class in the codebase on each invocation, cache results (Laravel cache or a build artifact) keyed by file path plus mtime. Never parse inside a request handler without caching.
Failure modes.
phpstan/phpdoc-parser upgrade — blocks the whole dependency graph, not just the feature. Highest-probability failure.phpstan/phpdoc-parser past the wrapper's constraint, behavior changes may surface as confusing downstream errors.Ramp-up. Low for anyone familiar with PHPStan-style tooling; ~half a day for a mid-level engineer to learn the node types (PhpDocTagNode, PropertyTagValueNode, MethodTagValueNode) and the AttributeAware gotchas. Non-trivial for engineers unfamiliar with AST traversal — the API returns node objects, not arrays, and requires recursive descent. Allocate a short internal write-up covering the internal interface, supported tag subset, and the "empty result means unsupported syntax, not an error" contract.
Bottom line. Adopt only as a dev-time or tooling dependency, behind an internal interface, version-pinned, with an explicit plan to replace it with direct phpstan/phpdoc-parser usage. The underlying parser is excellent; the wrapper is a convenience with no maintenance guarantee and should not be load-bearing.
How can I help you explore Laravel packages today?