Download the PHP package jdiassdev/laravel-types-gen without Composer
On this page you can find all versions of the php package jdiassdev/laravel-types-gen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jdiassdev/laravel-types-gen
More information about jdiassdev/laravel-types-gen
Files in jdiassdev/laravel-types-gen
Package laravel-types-gen
Short Description Generate TypeScript types from Laravel FormRequests and API Resources.
License MIT
Homepage https://github.com/jdiassdev/laravel-types-gen
Informations about the package laravel-types-gen
Laravel TypesGen
Generate TypeScript interfaces automatically from your Laravel FormRequests and API Resources. Keep your backend and frontend contracts in sync without any manual duplication.
Requirements
- PHP 8.2+
- Laravel 11 or 12
Installation
Install via Composer:
The service provider is registered automatically via Laravel's package discovery. No additional setup required.
Usage
Run the artisan command from your project root:
Two files are generated inside resources/types/:
| File | Source |
|---|---|
api-request.ts |
app/Http/Requests/**/*Request.php |
api-resource.ts |
app/Http/Resources/**/*Resource.php |
How it works
The package performs static analysis — it reads your PHP files directly without instantiating any class or booting the framework. This means it is safe to run at any point, including CI pipelines.
FormRequests
Both rule formats are supported.
String style
Array style
Generated output:
Fields that do not have the
requiredrule are emitted as optional (field?: type).
Nested fields
Dot-notation fields are converted into nested TypeScript objects and arrays.
API Resources
The package reads the return array of toArray() and extracts the field names. Since values depend on runtime data, all resource fields default to any.
Type mapping
| Laravel rule | TypeScript type |
|---|---|
string, email, url, date, uuid, ulid, ip, timezone, password |
string |
integer, numeric, decimal, float, double |
number |
boolean, accepted, declined |
boolean |
array |
any[] |
file, image |
File |
json |
any |
object |
Record<string, any> |
nullable modifier |
type \| null |
field without required |
field?: type |
Configuration
The output path can be customized. Publish the config file:
Testing
Changelog
Please see CHANGELOG for information on recent changes.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover a security vulnerability, please review our security policy and report it responsibly.
Credits
License
The MIT License. Please see LICENSE for more information.
All versions of laravel-types-gen with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/console Version ^11.0|^12.0
illuminate/filesystem Version ^11.0|^12.0