andydefer/php-signature-parser
A strict, typed parser for CLI signatures that extracts the command source, required and default arguments, nullables, variadics, enums, and flags using value objects and typed collections, with ^ spacing, inline comments, special tokens, and custom tags.
Architecture fit
The package is a standalone, framework-agnostic PHP 8.1+ library that parses Laravel/Artisan-style command signature strings into a typed object graph (SignatureStructureVO, ArgumentCollection, FlagCollection, EnumCollection, VariadicArgumentCollection). That positioning matters: it is a parser, not a console runtime. In a Laravel codebase, signature parsing already exists inside Illuminate\Console\Parser, which produces Symfony Console InputArgument/InputOption objects consumed by the framework's command registration. This package produces its own Value Objects instead, so it does not drop in as a replacement. Its natural architectural home is developer tooling and metadata extraction — signature linters, command documentation generators, scaffolding commands, custom PHPStan/Rector rules, IDE helper output — not the request/CLI execution path.
Integration feasibility
Composer-installable, MIT-licensed, no evident framework coupling, so installation cost is near zero. Real integration cost sits in the adapter layer: mapping the VO graph to Symfony's InputDefinition is required for any runtime-facing use, and that mapping is where subtle behavior differences surface (default values, array/variadic options, optional-value flags). A second friction point is dialect divergence — the package deliberately supports a superset syntax (^ whitespace formatting, inline comments, ? null token, _ skip token, custom tags). Signatures written for this parser would not be valid Artisan signatures, so the package must be used as a read-only analyzer of existing signatures unless a normalization step strips the extensions.
Technical risk
{--queue=}, array options {--tag=*}, short flags, {--} separator, escaped braces). Divergence here produces silent mis-parses rather than loud failures.InputDefinition cannot express enums natively — you will need your own validation/suggestion layer, which is bespoke code you own.Key questions
^/comment/tag extensions when they appear inside a signature intended for production?InputDefinition adapter, or is that entirely on us?Stack fit
Best suited to Laravel 10/11/12 projects on PHP 8.1+ as a dev dependency first. Fits cleanly behind an internal interface (e.g. CommandSignatureParser) so the concrete implementation is swappable and the rest of the codebase never touches the third-party VOs directly. Poor fit as a runtime dependency in the console bootstrap without a proven adapter and differential test coverage.
Migration path
Do not replace Illuminate\Console\Parser. Introduce this parser alongside it behind an abstraction, and initially use it only for read-only consumers (documentation generation, signature linting, command inventory). Only consider runtime substitution — if ever — after the differential suite is green across the full command corpus.
Compatibility
SignatureStructureVO → InputDefinition, plus a reverse-path comparison against Laravel's own parser.^, inline comments, and custom tags in any signature string destined for Artisan.Sequencing
Illuminate\Console\Parser.InputDefinition adapter and the differential/golden-corpus test suite.Maintenance The primary cost is ownership transfer: with one maintainer and no dependents, assume you may need to vendor or fork the package. Budget for that explicitly — a fork under the org's namespace is cheap given the small surface area, and removes the abandonment risk. The adapter and golden-corpus tests are permanent internal assets regardless of which parser you use.
Support No community, no Stack Overflow corpus, French-only documentation. Support tier is "internal L1/L2" — the team absorbs all bug triage. Mitigate by keeping the integration surface small and behind an interface so an internal reimplementation is a contained effort.
Scaling Parsing cost is negligible for hundreds of commands, but if used in the console bootstrap, results should be cached (e.g. compiled to a manifest at build/deploy time) rather than parsed on every invocation. For tooling use, no scaling concern.
Failure modes
InputDefinition → commands accept/reject the wrong arguments at runtime. Highest-severity failure; the differential suite is the control.$signature string, breaking Artisan's own parser.InputDefinition internals.Ramp-up
Small and self-documenting surface: engineers familiar with Artisan signatures can read the VO graph in well under a day. The real ramp-up cost is the custom dialect (^, ?, _, tags) — roughly half a day of documentation review, best captured as a short internal ADR with the golden-corpus test as the executable spec. Total onboarding estimate: 1–2 engineer-days for a mid-level developer to contribute confidently to the integration.
How can I help you explore Laravel packages today?