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.
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.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.Adopt when:
types.d.ts or equivalent and it has drifted, or you have no types at all and want them without a contract-first redesign.morphTo) relations, and you can run PHP as part of the frontend build or a CI step.Notifiable/DatabaseNotification, request-dependent relations — without aborting the publish run.Look elsewhere when:
unknown, so the value proposition shrinks sharply.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.
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.
How can I help you explore Laravel packages today?