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

Laravel Ts Publish Laravel Package

abetwothree/laravel-ts-publish

A Laravel package for publishing TypeScript definitions from your application. It streamlines keeping PHP and TypeScript types in sync, reducing manual duplication and helping frontend and backend stay aligned in TypeScript-powered Laravel projects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for the API contract layer. This package makes "generate TypeScript types from Eloquent models" a viable in-house option instead of adopting a heavier schema-first pipeline (OpenAPI codegen, GraphQL, shared Zod schemas). It is a small, incremental dependency rather than a platform migration, so it competes favorably on cost and time-to-value for Laravel-centric teams.
  • Roadmap sequencing for a TypeScript migration. If the roadmap includes moving Blade/jQuery screens to Inertia + React/Vue with TypeScript, this is a credible prerequisite: it gives the frontend real types without a backend rewrite. It also sets a realistic expectation — strictness improves progressively as generated types get cleaner, not on day one.
  • Feature scoping and estimation confidence. Typed model, enum, and resource shapes mean frontend work on forms, filters, status badges, and relation-driven UI can be scoped against the actual payload shape instead of guesswork. Fewer "we didn't know that field was nullable" surprises mid-sprint.
  • Adoption/trust health of the type pipeline. v2.7.0 is largely a trust release. Most of the fixes eliminate false-positive TypeScript errors and broken imports — the failure mode that causes teams to stop believing the generated types and quietly hand-write overrides. For a PM, that is the difference between a tool that sticks and one that gets ripped out two sprints later.
  • CI gating policy. The new ts:publish warnings (duplicate enum names, unreadable relations, unreadable related models) are actionable, build-time signals. That enables a decision to treat type generation as a gated CI step rather than a developer-local convenience.
  • Known-limitation tracking. Classes the package doesn't generate (service classes, DTOs) now come out as unknown instead of a broken import. That is the right failure mode, but it means part of the domain layer is effectively untyped in the frontend — worth logging as a scoped gap with an owner rather than letting it silently accumulate.

When to Consider This Package

Adopt when:

  • The backend is Laravel and the frontend is TypeScript (Inertia/Vue/React, or a TS client consuming your API), and Eloquent is your de facto source of truth.
  • You currently hand-maintain a types.d.ts or equivalent and it has drifted, or you have no types at all and want them without a contract-first redesign.
  • You want models, enums, and API resources typed from one place, including polymorphic (morphTo) relations, and you can run PHP as part of the frontend build or a CI step.
  • You need the type surface to survive real-world messiness — vendor package models, Notifiable/DatabaseNotification, request-dependent relations — without aborting the publish run.
  • You are willing to accept a single-maintainer open-source dependency in the build toolchain and pin versions accordingly.

Look elsewhere when:

  • The API is public, or consumed by non-TypeScript clients, and needs a language-agnostic contract — go OpenAPI/schema-first instead.
  • Your domain logic lives in DTOs, services, or actions rather than Eloquent models; those will publish as unknown, so the value proposition shrinks sharply.
  • Frontend builds run in an environment without PHP (fully decoupled CI/CD, separate frontend repo with no PHP runtime).
  • You need runtime validation, not just compile-time types — pair with or replace by Zod/Valibot.
  • You have multiple backend services or non-Laravel domain models; a shared schema layer is the better long-term investment.

Upgrade risk for v2.7.0: this is a minor release with no deprecations or breaking changes called out. It is a low-risk upgrade, and the automatic publishing of related models is the one behavior change worth flagging — teams with carefully curated models.additional_directories may see their generated output grow, which is intended but should be reviewed in a PR diff rather than merged blind.

How to Pitch It (Stakeholders)

To executives: This is a free, open-source Laravel package that generates our frontend TypeScript types directly from our backend models — one source of truth, no manual syncing, no vendor contract. The immediate business value is fewer frontend/backend contract bugs and faster delivery on UI work, because the frontend is coded against the real data shape. The v2.7.0 release is about reliability: it removes a class of generated-type errors that would otherwise erode developer trust and cost us rework, and it makes type generation safe to run as an automated CI check. Adoption is incremental and reversible — no backend rewrite, no new platform.

To engineering: v2.7.0 fixes the failure modes that made the generated output noisy. Related models outside configured directories (vendor models, DatabaseNotification via Notifiable) are now published automatically, so relation imports resolve without maintaining additional_directories; excluded models and missing tables are skipped. Two classes sharing a name now get distinct aliases across unions, when(), ternaries, morphTo resources, and docblock unions, so unions no longer silently drop a member. laravel-ts-global.ts no longer fails to parse on multi-word namespace segments (ReportCards → reportCards, not report-cards) — previously one bad segment broke the entire declaration file. {Model}All compiles when a relation shares a name with a column or accessor. Duplicate imports and imports of non-existent files are gone; ungeneratable classes publish as unknown instead of a broken import. Relations that throw (e.g. request-dependent) no longer abort ts:publish, and --only-resources/--source runs now type morphTo unions consistently with full runs. New warnings after publish give us a lint-style signal for duplicate enum names and unreadable relations — use these to gate CI. Action items: review the generated diff before merging (output will grow from auto-published related models), and pin the version given the single-maintainer dependency.

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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings