Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Typescript Generator Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The capability is right; the packaging is wrong for a Laravel shop. janit/typescript-generator-bundle is a Symfony Bundle, not a Laravel package — it registers into a Symfony kernel, wires through Symfony DI, and exposes its logic as a tagged Symfony console command. Laravel has no bundle mechanism and no equivalent auto-registration, so composer require will not yield a usable php artisan command. What is genuinely reusable is the technique: reflect over PHP classes and emit TypeScript interfaces for DTOs, request/response models, and form objects. Treat the repo as a reference implementation and candidate core library, not a dependency. That reframing is the central TPM judgment here, because it determines whether the effort is "a day or two of glue" or "a platform commitment."

Integration feasibility. Two viable paths, and the effort differs by an order of magnitude. (1) Fork/adapt: lift the generator service, discard the Symfony wiring, and re-register behind a single Artisan command in a service provider — roughly one to two days assuming the reflection logic is cleanly separated from the bundle plumbing. (2) Consume a sibling core: bundles of this shape usually wrap a standalone, framework-free generator library, in which case the correct move is to depend on that core directly and write ~100 lines of Artisan glue. Resolve which of these is true before any commitment — it is the single highest-leverage question in this evaluation.

Technical risk. Mostly sustainability, not correctness.

  • Unproven adoption: 16 stars, 0 dependents, composite score 0.43. No observable production usage anywhere.
  • Bus factor of one. Single-maintainer project with no downstream consumers means no implicit regression testing and no pressure to track PHP/Symfony releases.
  • Version drift. The reflection surface (enums, readonly, union/intersection types, promoted constructor params) moves with every PHP minor. An unmaintained reflector will silently emit incomplete TypeScript — the worst failure mode, because the output type-checks and looks plausible.
  • Semantic gap. PHP does not map cleanly to TypeScript: int/float → number, array variance, nullable | null vs optional ?, and generics visible only via docblock parsing. Without a deliberate mapping table the output is lossy and teams patch it by hand, defeating the purpose.
  • MIT license is the main mitigant — forking is legally unencumbered, so the abandonment scenario is survivable.

Key questions.

  1. Does the bundle delegate to a standalone, framework-free generator library we can depend on directly?
  2. Which PHP versions and type constructs are covered by tests — enums, readonly, union types, generics/docblocks?
  3. Is output deterministic and diffable (stable ordering and formatting) enough to live in CI without churn?
  4. What is the last-commit date and release cadence? Any open issues on PHP 8.2+/8.3+?
  5. Can it target specific namespaces with exclusions, or does it assume a conventional Symfony src/ layout?
  6. Where do generated .ts files live — committed to the frontend repo, or published as a build artifact?

Integration Approach

Stack fit. Runtime is PHP (Laravel), frontend is TypeScript. The need — one source of truth for DTO shapes across the boundary — is real and this package addresses it. The fit is indirect: a Symfony-shaped solution to a framework-agnostic problem. Adopt the technique, not the bundle.

Migration path. There is no migration; there is an adoption of the underlying capability.

  1. Spike (½–1 day). Stand up a throwaway minimal Symfony skeleton (never touching the Laravel runtime), point it at a handful of representative Laravel DTOs/FormRequests/Resources, and inspect the emitted TypeScript. This cheaply answers the quality and semantic-mapping questions and de-risks everything downstream.
  2. Extract. If output quality is acceptable, vendor the core library via Composer or fork the generator into app/Support/TypeGen, and register one Artisan command — e.g. php artisan types:generate --namespace=App\\Data --out=resources/js/types/generated.ts.
  3. Harden. Add a golden-file test: a fixture directory of PHP classes with committed expected .ts output, asserted in CI. This is the single most valuable engineering artifact here — it converts an unmaintained dependency into pinned, verifiable behavior.
  4. Automate. Run generation in CI on PRs touching DTO namespaces and fail on drift against committed output.

Compatibility. Confirm the fork runs on our exact PHP minor (Laravel 10/11 implies PHP 8.1–8.3) before step 2. If upstream predates enums or readonly classes, patching is likely cheaper than replacing — but budget for it. On the TypeScript side, generated output must satisfy the frontend's strict/noImplicitAny settings; nullable handling that produces implicit any will break the build.

Sequencing. Spike before commitment; extraction and golden-file test as one unit of work; automate last. Do not begin by integrating the Symfony bundle into the Laravel app — that path has no clean endpoint.

Operational Impact

Maintenance. The dominant cost, and it lands on us, not the maintainer. Once forked, we own the reflection logic against every PHP upgrade: a few hours per PHP minor plus ad-hoc fixes when a developer hits an unsupported construct. Small but permanent, and it will never appear on a roadmap. Mitigate by keeping the fork thin — glue and a mapping table only — and vendoring the generator core unmodified so upstream fixes can be pulled if they ever arrive.

Support. No vendor, no SLA, no community to escalate to. Internal ownership must be explicit and named; an unowned fork becomes abandoned code within two quarters. Documentation should state plainly: "generated file, do not edit; regeneration command is X."

Scaling. Generation cost is linear in reflected classes — seconds at realistic DTO counts, a non-issue. The real scaling concern is organizational: as DTO volume grows, semantic-mapping edge cases multiply (nested collections, polymorphic payloads, mixed), each a small bespoke decision. Centralize the mapping table so those decisions are reviewable rather than scattered across the codebase.

Failure modes.

  • Silent type drift — the most dangerous. A PHP change the generator mishandles produces TypeScript that compiles cleanly but is wrong at runtime. The golden-file test catches changes, not incorrect mappings; pair it with runtime validation (Zod or equivalent) at the API boundary where correctness matters.
  • Generation skipped — a developer edits a DTO and forgets to regenerate, leaving committed .ts stale. Enforce via CI drift check, never by convention.
  • Upstream abandonment — low impact if forked; fatal if the bundle is depended on directly.
  • Scope creep — pointed at Eloquent models or framework internals, output becomes noise. Namespace allow-listing is mandatory.

Ramp-up. Low for the concept, moderate for the ownership burden. A mid-level engineer completes the spike and Artisan command in 2–3 days. The substantive ramp is organizational: frontend and backend must agree that generated types are authoritative and hand-edited interfaces are prohibited outside the generated file. Without that agreement, teams maintain parallel hand-written types and the tool becomes pure overhead.

Recommendation. Worth a one-day spike, not worth a direct dependency. The problem is real, the package is the right shape of solution for the wrong framework, and the weak adoption signals mean the durable deliverable is a small, well-tested in-house Artisan command with a golden-file test — using this repo as its starting point and reference.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log