pentacore / laravel-typefinder
Auto-generate TypeScript type definitions from Laravel Models, Enums, Casts, and Requests.
Requires
- php: ^8.3
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/database: ^11.0|^12.0|^13.0
- illuminate/filesystem: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- illuminate/validation: ^11.0|^12.0|^13.0
Requires (Dev)
- laravel/boost: ^2.4
- laravel/pint: ^1.21
- orchestra/testbench: ^10.1|^9.0|^11.0
- phpunit/phpunit: ^11.0|^10.5
- rector/rector: ^2.0
- dev-master
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.0.1
- 3.0.0
- 2.0.0
- 1.3.0
- 1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- dev-dependabot/npm_and_yarn/development/semantic-release/github-12.0.8
- dev-dependabot/npm_and_yarn/development/vitest-4.1.6
- dev-dependabot/npm_and_yarn/development/typescript-eslint-8.59.3
- dev-dependabot/github_actions/development/actions/dependency-review-action-5
- dev-dependabot/npm_and_yarn/npm_and_yarn-053c9c4054
- dev-dependabot/npm_and_yarn/development/vite-7.3.3
- dev-dependabot/npm_and_yarn/packages/vite-plugin-laravel-typefinder/development/vite-7.3.3
- dev-development
- dev-dependabot/npm_and_yarn/development/vite-plugin-dts-5.0.0
- dev-dependabot/npm_and_yarn/packages/vite-plugin-laravel-typefinder/development/vite-plugin-dts-5.0.0
- dev-claude/fix-typescript-declaration-gZR1B
This package is auto-updated.
Last update: 2026-05-15 06:37:36 UTC
README
Laravel Typefinder auto-generates TypeScript type definitions (.d.ts files) from your Laravel application. It introspects Eloquent models, backed enums, Form Requests, API Resources, Inertia controllers, broadcast events, and pivot tables to produce accurate, always-fresh types — no manual maintenance required. Ships with opt-in attributes (#[TypefinderOverrides], #[TypefinderWriteShape], #[TypefinderResource], #[TypefinderPage], #[TypefinderBroadcast], #[TypefinderCast], #[TypefinderIgnore]) for the cases where static inference needs a nudge, plus a runtime facade for registering types for third-party casts.
Contents
- Packages
- At a glance
- Quick start
- Supported matrix
- Documentation
- Development
- Contributing
- Security
- License
Packages
| Package | Install |
|---|---|
pentacore/laravel-typefinder |
composer require pentacore/laravel-typefinder |
@pentacore/vite-plugin-laravel-typefinder |
npm i -D @pentacore/vite-plugin-laravel-typefinder |
At a glance
You write this:
// app/Models/Post.php class Post extends Model { protected $casts = [ 'status' => PostStatus::class, 'published_at' => 'datetime', ]; public function author(): BelongsTo { return $this->belongsTo(User::class); } }
Typefinder emits this:
// resources/js/typefinder/models/Post.d.ts import type { PostStatus } from '../enums'; import type { User } from './User'; export type Post = { id: number; title: string; status: PostStatus; published_at: string | null; author?: User | null; }; export type PostCreate = { title: string; status: PostStatus; published_at?: string | null }; export type PostUpdate = { title?: string; status?: PostStatus; published_at?: string | null };
No decorators, no manual schemas — it reads your migrations, $casts, and relationships directly.
Quick start
1. Install the Composer package:
composer require pentacore/laravel-typefinder
2. Register the Vite plugin (vite.config.js):
import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import typefinder from '@pentacore/vite-plugin-laravel-typefinder'; export default defineConfig({ plugins: [ laravel({ input: ['resources/js/app.js'] }), typefinder(), ], });
3. Generate types:
php artisan typefinder:generate
Types are written to resources/js/typefinder/ by default. The Vite plugin re-runs generation automatically on HMR file changes.
Supported matrix
Every cell below is exercised in CI on every push and PR.
| PHP 8.3 | PHP 8.4 | PHP 8.5 | |
|---|---|---|---|
| Laravel 11 | ✅ | ✅ | — |
| Laravel 12 | ✅ | ✅ | ✅ |
| Laravel 13 | ✅ | ✅ | ✅ |
Documentation
Full documentation for each package:
- packages/laravel-typefinder/README.md — configuration, every generated category (models / enums / requests / resources / pivots / pages / broadcasting / helpers), the full attribute reference, the third-party cast registry, and the artisan commands (
typefinder:generate,typefinder:watch) with flags (--check,--json,--debug,--only=). - packages/vite-plugin-laravel-typefinder/README.md — plugin options, debounce behaviour, alternative install from vendor
Development
# Install PHP dependencies composer install # Install JS dependencies npm install # Run PHP tests vendor/bin/phpunit # Check PHP code style vendor/bin/pint --test # Build the Vite plugin npm -w packages/vite-plugin-laravel-typefinder run build # Lint the Vite plugin npm -w packages/vite-plugin-laravel-typefinder run lint
Contributing
Bug reports, feature proposals, and PRs are welcome. Start with CONTRIBUTING.md — it covers the commit-message convention (Conventional Commits), the pre-commit toolchain (pint, rector, npm run lint), and the CI matrix your changes need to pass.
Security
If you've found a security issue, please follow the disclosure process in SECURITY.md rather than opening a public issue.
License
MIT — see LICENSE.