nette/php-generator
Nette PHP Generator lets you build PHP classes, interfaces, traits, enums, methods and complete files programmatically, with clean pretty-printing, full modern PHP support and a fluent API. Ideal for scaffolding, ORMs and code generators.
Architecture fit: The package remains a pure PHP code generator with no framework coupling, so it slots cleanly into Laravel's MVC structure as a scaffolding/emit layer — generating models, controllers, migrations, form requests, or custom artisan-driven scaffolding. Its namespace and FQN handling (PhpFile::add(), ClassType::from()) maps directly onto Laravel's PSR-4 autoloading conventions. It still lacks Laravel-specific abstractions (no Eloquent-aware model generation, no schema-to-migration awareness), so a thin internal adapter remains the recommended pattern: our own generators describe intent, this package handles the AST/emit and file-writing concerns. v4.2.3 does not change this fit.
Integration feasibility: High. Install via Composer; the package requires PHP 8.1+ and now declares support through PHP 8.6 (new in v4.2.3), which extends the forward-compatibility runway rather than constraining it. Note this is a support statement, not a raised floor — projects on PHP 8.2/8.3 (the realistic Laravel 10/11/12 baseline) are unaffected and no lockfile churn is expected beyond the patch bump. Dependency on nette/utils (v4.0.6+) is already satisfied in most Laravel ecosystems. Static analysis (PHPStan) remains in the codebase, lowering integration risk. The v4.2.3 bug fix (typed class constants now retain their type through ClassType::from() / fromCode()) is a correctness improvement that only matters if we generate classes with typed constants (PHP 8.3+); it removes a latent silent-failure path rather than adding work.
Technical risk: The critical license ambiguity persists — "NOASSERTION" in package metadata against an MIT indication on the GitHub repository — and v4.2.3 does nothing to resolve it. This remains the gating item for commercial use and should be treated as a blocker until legal confirms. Secondary risks: the dependents count (0 reported) still contradicts the star count and Nette-ecosystem usage, so adoption-signal data should be treated as unreliable rather than as evidence of low quality; the release cadence data still contains a future-dated entry, so treat timeline metadata as low-confidence. The v4.0+ BC surface (ClassType splitting, deprecated parameters) means we must pin to a minor range (^4.2) rather than float. Forward support for PHP 8.6 is a mild positive signal on maintenance, but it also implies the maintainer tracks unreleased runtimes, so we should not assume PHP 8.6 availability in our own CI as a dependency of this package.
Key questions:
php constraint floor, or only an upper-bound relaxation? (Verify in composer.json before bumping.)Stack fit: Laravel 10/11/12 on PHP 8.2–8.4 as the primary target, with PHP 8.5/8.6 as a forward path now that the package declares support. The package sits inside our generator layer, invoked from artisan commands and CI scaffolding jobs — it is not a runtime dependency of the application, which keeps blast radius small.
Migration path: Adopt at ^4.2 pinned. Because this is generator-only, integration can be done behind an internal Scaffolder interface with the package as the sole implementation, so a future swap (or a fork, if licensing forces it) is a contained change. No data migration, no schema change, no runtime behavior change for existing requests.
Compatibility: No breaking changes in v4.2.3 — additive PHP version support plus a bug fix. Existing v4.2.x code paths are untouched. The typed-class-constant fix could change output for generators that emit typed constants: previously emitted files may have dropped the type; after the bump, regenerated files may include it. That's a diff to review, not a break, but it means any golden-file/snapshot tests over generated output should be re-baselined as part of the upgrade.
Sequencing:
composer.json constraint change for PHP 8.6 and confirm it is not a floor raise.^4.2.2 → ^4.2.3 in a single PR; run PHPStan and the generator test suite.Maintenance: Low ongoing cost — the package is a build-time tool with a narrow surface. The main maintenance obligation is version discipline: pin to ^4.2, review each 4.x release for BC notes given the v4.0 history, and keep a short internal changelog of behavior changes that affect generated output. The v4.2.3 upgrade is a routine patch bump.
Support: No vendor support relationship exists; we are dependent on an open-source maintainer. Mitigation is the wrapper interface plus a small, well-understood call surface — a fork or replacement is feasible if maintenance stalls. Licensing ambiguity remains the top support risk because it can force a change of direction regardless of technical quality.
Scaling: Negligible runtime scaling impact — generation happens in CI and developer machines, not per-request. Cost scales with the number of generator invocations, not traffic. For large monorepos generating many files, watch filesystem I/O and idempotent overwrite behavior rather than CPU.
Failure modes:
Ramp-up: Low. For a TPM, the ramp is mostly about constraining scope: the team needs to learn the PhpFile / ClassType API surface and our adapter conventions, roughly a day for a mid-level engineer. The larger onboarding cost is procedural — teaching the team that generated code is tested via snapshots and that the package is pinned and gated on license review. Budget one short spike to confirm PHP-constraint semantics and re-baseline snapshots; no broader enablement program is warranted for a patch release of this size.
How can I help you explore Laravel packages today?