Download the PHP package hemilrajput/laravel-typegen without Composer
On this page you can find all versions of the php package hemilrajput/laravel-typegen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hemilrajput/laravel-typegen
More information about hemilrajput/laravel-typegen
Files in hemilrajput/laravel-typegen
Package laravel-typegen
Short Description Generate TypeScript types from Eloquent models, Enums & FormRequests.
License MIT
Informations about the package laravel-typegen
Laravel TypeGen
Laravel TypeGen — one artisan command turns your Eloquent models, Enums, and FormRequests into a single typed
.tsfile. No more hand-syncing PHP and TypeScript.
📖 Documentation
For complete documentation, guides, and setup instructions, visit laravel-typegen.github.io.
Why Laravel TypeGen?
- Keeps types in sync: Automatically reflect changes in your PHP models in your TypeScript interfaces. Generate TypeScript types from Eloquent models, Enums, and FormRequests. Built for the Laravel 13 + Inertia + React/Vue stack.
⚡️ The Killer Feature: Synchronized Types
Laravel TypeGen doesn't just generate standalone interfaces. It understands your application's logic.
PHP Enum + Model Cast:
TypeScript Output:
🚀 Features
- Eloquent Models: Generates interfaces from
$fillable,$casts, and timestamps. - Enums: Generates union types from backed and pure PHP enums.
- FormRequests: Generates request DTOs from your
rules()method. - Attribute-Driven: Opt-in to generation using the
#[TypeScript]attribute. - Zero-Config: Smart defaults for standard Laravel projects.
📊 Comparison
| Feature | TypeGen | Spatie TS Transformer |
|---|---|---|
| Eloquent Support | ✅ | ✅ |
| Enum Support | ✅ | ✅ |
| FormRequest → DTO | ✅ | ❌ |
| Relationship Auto-Discovery | ✅ | ❌ |
| Linked Enum Casts | ✅ | ⚠️ (Manual) |
| Attribute Driven | ✅ | ✅ |
| Inertia Native | ✅ | ⚠️ |
📦 Installation
🛠 Usage
1. Tag your classes
2. Generate
🔗 Relationships
Opt into relationship type generation per-model:
Related models (Post, Profile) are auto-discovered — no need to mark them separately. Generated output:
Relations are always emitted as optional (?) because they're only present when eager-loaded. This matches runtime reality.
Polymorphic relations
MorphTo is auto-supported when you register a morph map:
Generates:
Without a morph map, emits unknown | null with a comment.
🗺 Roadmap
- [x] Enum support (v0.2)
- [x] FormRequest → DTO (v0.2)
- [x] Eloquent relationships (v0.3)
- [x] Route parameter types (v0.4)
- [x] Watch mode (v0.4)
- [x] Custom Cast class resolver (v0.4)
- [x] VitePress documentation site (v1.0.0)
- [x] Stable release (v1.0.0)
Configuration
See config/typegen.php for all available options, including:
- Output path and style (interface vs type).
- Custom cast mapping.
- Prefix/suffix for generated names.
- Including/excluding timestamps and hidden fields.
License
MIT
All versions of laravel-typegen with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0