janit/typescript-generator-bundle
A Symfony bundle that generates TypeScript definitions from PHP classes, helping keep frontend and backend types in sync. It automates type generation so TypeScript clients stay aligned with your application models.
openapi-typescript. The honest read: for a Laravel stack, this is a reference implementation for option (b), not a drop-in for option (a) — it is a Symfony Bundle with no Laravel auto-discovery, no extra.laravel wiring, and no Artisan command.Consider it when:
Look elsewhere when:
composer require'd into Laravel and work — no bundle registration, no Symfony DI compilation, no tag-based command discovery. Budget a day or two of extraction work; verify first whether the bundle wraps a framework-free core library you can depend on directly (that changes effort by an order of magnitude).any would fail your tsconfig strict/noImplicitAny settings.The dominant risk to price in: silent type drift. An unmaintained reflector facing PHP 8.2/8.3 constructs (enums, readonly, unions, promoted params) will emit TypeScript that compiles fine and is wrong at runtime — the worst failure mode. A golden-file test catches changes, not incorrect mappings; pair with runtime validation at the boundary if correctness matters.
To executives: a small MIT-licensed tool that turns our PHP models into TypeScript interfaces automatically, eliminating a recurring class of frontend/backend integration bugs and removing manual type maintenance from every API change. Cost is effectively zero and the risk is contained — it runs at build time as a console command, never in production request paths. Recommend funding a one-sprint spike, not a platform standard, until it proves out on one bounded module.
To engineering: be straight about the mismatch. This is a Symfony command, not a Laravel package — no auto-discovery, no Artisan integration. The underlying capability (reflect over PHP classes, emit .ts interfaces) is framework-agnostic; the delivery is Symfony glue. The cheap path is a half-day spike in a throwaway Symfony skeleton pointed at a few representative DTOs to answer the quality and type-mapping questions, then — if output is acceptable — lift the generator into app/Support/TypeGen behind a thin php artisan types:generate --namespace=App\\Data --out=resources/js/types/generated.ts. Add a golden-file test; that is the single most valuable piece of engineering here, because it converts an unmaintained dependency into pinned, verifiable behavior. Vendored the core unmodified so upstream fixes can be pulled if they arrive.
The trade we're accepting, stated plainly: low adoption signals (16 stars, 0 dependents, one maintainer) mean we own the reflection logic against every PHP minor upgrade — a few hours per release, permanently, and invisible on any roadmap. Mitigate by keeping the fork thin (glue plus a single centralized type-mapping table), naming an explicit internal owner, and documenting "generated file, do not edit; regenerate with X." Enforce regeneration via a CI drift check, not convention. On the frontend side, get explicit agreement that generated types are authoritative — without that, teams maintain parallel hand-written interfaces and the tool becomes pure overhead.
Bottom line: the problem is real and this is the right shape of solution for the wrong framework. Fund a one-day spike; treat any durable artifact as a small, well-tested in-house Artisan command with this repo as its starting point and design reference.
How can I help you explore Laravel packages today?