ajthinking/archetype
Archetype is a Laravel code generation package that lets you define models, migrations, controllers and more through a fluent PHP API, then scaffolds the files instantly—speeding up new features and project setup.
The core decision this informs: whether to build developer-facing code manipulation (generation, codemods, refactoring) in-house or buy the AST plumbing and spend the team's time on the product layer instead.
nikic/php-parser directly. That's the honest comparison: Archetype is a convenience layer (fluent query builder, node insertion, format-preserving printing) over php-parser. The buy decision is roughly "a few weeks of engineering to get to parity" versus the maintenance and upgrade risk of a 271-star, single-maintainer package.Good fit when:
nikic/php-parser ^5. The 2.0.1 CI matrix verifies twelve PHP × Laravel combinations, plus macOS and PHPStan — that is real evidence, not assumption, and it is the single best maturity signal here.LICENSE.md now exists — it was missing until 2.0.1).Look elsewhere or defer when:
statamic/cms is named as the largest consumer and was validated byte-identically against 2.0.0.^8.1 upper bound exists because PHP 9 removes dynamic properties and the AST node-identity mechanism depends on them. Composer refusing to install is the intended behavior, but it does mean a PHP 9 migration will require an Archetype-compatible replacement, not just a version bump.Risk mitigations worth committing to before adoption: wrap it behind a narrow internal adapter interface so a future swap to raw php-parser is contained; pin ^2.0; and treat the 1.x → 2.x break as the one upgrade to plan for now rather than later.
To executives (30 seconds): This is a free, MIT-licensed library that lets our code write and modify other code. It is what powers Laravel Blueprint, and Statamic — a large commercial Laravel package — is its biggest consumer and was explicitly regression-tested against this release. It saves us the several weeks of engineering it would take to build PHP source editing ourselves. It ships at build time, not in production, so the downside if it disappoints is a contained tooling delay, not a customer-facing incident. Cost: zero license, plus an estimated one-to-two-week spike to prove it on a real use case.
To engineering leadership: Mature enough to bet a tooling roadmap on, with eyes open. The 2.0.1 release is exactly the kind of release you want to see from a small dependency: no API changes, a declared php requirement where none existed, a missing license file added, seven PHP 8.4 deprecation fixes, a real bug fix (->throw() had silently matched nothing since 2.0.0; getReflection() was catching Exception where it needed Throwable), and CI rebuilt against a pinned Laravel skeleton because Laravel 11 deleted the files the old suite depended on. That is a maintainer cleaning house rather than adding surface area. It is also a single-maintainer project with modest public adoption signals, so the recommendation is adopt behind an adapter, not adopt and spread.
To the engineering team: You get a fluent query-and-transform API over nikic/php-parser, format-preserving output, and a working Maker pattern for generation. You inherit two real costs: thin documentation you will learn from tests and source, and a dependency chain on php-parser 5 that you should pin deliberately. Start with one vertical slice — a single codemod or generator — and measure whether the abstraction earns its keep versus going direct to php-parser.
The ask: a time-boxed spike on one concrete use case, with a go/no-go gate at the end. Success looks like working tooling in days rather than weeks; failure looks like fighting the docs, in which case the fallback to raw php-parser is a small, well-understood rewrite because the domain is the same.
How can I help you explore Laravel packages today?