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.
Architecture fit
ajthinking/archetype is not a scaffolding framework in the artisan make:* sense — it is an AST-level code manipulation library built on nikic/php-parser. Its value to a TPM is as internal engineering enablement: scripted, repeatable edits to PHP source (class/method/property/constant creation, insertion and removal, node query-and-replace), rendered back with format-preserving pretty printing so diffs stay minimal and reviewable.
That places it squarely in the developer toolchain layer, not the request path. The first architectural decision is therefore containment: either it lives in a require-dev/build-time capacity (custom Artisan generators, refactoring utilities, upgrade scripts), or it becomes a runtime dependency because a product feature generates PHP for end users. Those are different risk profiles and should be decided explicitly, not discovered later. The natural alternative — stub files plus string replacement — is simpler and dependency-free but breaks down exactly where Archetype earns its keep: modifying existing code (Laravel 11+ skeletons, service provider registration, config edits) without collateral formatting churn.
Integration feasibility
High. Composer install, Laravel service provider auto-discovery, a publishable config. The 2.x line is verified in CI across twelve PHP × Laravel combinations (PHP 8.1–8.4; Laravel 10, 11, 12, 13) and checked against real Statamic 5/6 installs producing byte-identical output to the prior release. The hard external constraint is the nikic/php-parser ^5.0 pin, which is ubiquitous enough to be a low-collision dependency but is still a major-version constraint we do not control.
Technical risk
php ^8.1 with a deliberate upper bound, so Composer will refuse the install rather than ship a fatal — good behaviour, but it means Archetype is a blocker on any PHP 9 migration timeline and needs to be tracked as such now.->throw() node mapping that had matched nothing since 2.0.0, a getReflection() bug where one unloadable parent class or trait killed an entire query, PHP 8.4 deprecations, and incorrect commands_root/controllers_root config defaults. Anything below 2.0.1 is not a defensible baseline.Key questions
str_replace genuinely cannot handle? If not, the dependency is not yet justified.Stack fit
Strong for Laravel 10–13 on PHP 8.1–8.4. The dependency graph is shallow (nikic/php-parser plus Laravel support), and the package is explicitly tested against a pinned Laravel application skeleton rather than assumed compatible. The 1.x line is a dead end: it pins php-parser ^4.11 and cannot coexist with Pest 3 or anything else on v5.
Migration path
^2.0.1 only. Treat 2.0.0 as unsafe due to the throw and reflection bugs.php-parser major. The trigger to move is usually Composer refusing to resolve Archetype because something else needs php-parser v5 (Pest 3 being the common case). Run composer why nikic/php-parser before and after to confirm exactly one major resolves.Compatibility guardrails
Pin ^2.0.1. Hold PHP at ^8.1 with an explicit upper bound mirrored in our own composer.json so the PHP 9 conflict surfaces in CI, not in an incident. Add a CI check that fails if the resolved php-parser major changes. Publish and version-control the config, correcting commands_root/controllers_root if we touch either.
Sequencing
PhpSourceEditor) so call sites express intent, not AST node types. This is what makes the PHP 9 fork or a replacement library a contained change rather than a rewrite.--dry-run backed by ->preview().Maintenance
The package is in a stable, maintenance-oriented posture: changelog, semver releases, Dependabot configured, and a maintainer who responded to a two-year CI gap with a correctness-and-evidence release rather than feature churn. That is a good signal. The offsetting reality is that the ecosystem's maintenance is effectively subsidised by Statamic; if Statamic migrates off, our risk increases without any visible change on our side. Mitigation: named internal owner, version pin, and a documented fork procedure.
Support
Thin. Documentation is the weakest dimension, with operational detail living in release notes and source. Budget internal enablement rather than assuming vendor-style support; there is no commercial backing.
Scaling
Parsing is per-file, in-process, and CPU-bound — fine for tens to low hundreds of files. Bulk operations across a large monorepo need chunking, idempotency checks, and ideally parallel workers. The scaling limit is rarely throughput; it is the cost of reviewing large automated diffs and the blast radius of a bug that rewrites many files incorrectly in one run.
Failure modes to design against
Throwable rather than Exception), but the lesson generalises: process files independently and report per-file outcomes.Ramp-up
Moderate. A competent Laravel engineer becomes productive in a few days, but the fluent query builder has real idioms — higher-order where clauses, ->stmts without parentheses, closure-based insertStmt with a BuilderFactory — that are learned from source and release notes. Budget senior time for the first non-trivial transform and treat that engineer as the owner; the risk with this library is not that it fails loudly, but that a junior developer writes a transform that appears to work and quietly mangles a file.
How can I help you explore Laravel packages today?