illuma-law/laravel-wayfinder-forge
Composer 安装命令:
composer require illuma-law/laravel-wayfinder-forge
包简介
Auto-generate strongly typed frontend SDKs from Laravel Wayfinder routes.
README 文档
README
Auto-generate strongly typed frontend SDKs from your Laravel backend routes and FormRequests.
Wayfinder Forge ensures your frontend client code stays perfectly in sync with your backend validation rules. It parses your Laravel routes, reflects on their FormRequest or Spatie\Data classes, and automatically generates a ready-to-use TypeScript SDK.
Features
- TypeScript Interface Generation: Automatically converts Laravel validation rules (
required,string,nullable,array) into accurate TypeScript interfaces. - Spatie Laravel Data Support: First-class support for
spatie/laravel-dataDTOs. - Multiple Client Support: Generates SDKs formatted for
axios, standardfetch, orinertia. - Customizable Output: Easily define which routes to include/exclude via prefixes and middleware filters.
Installation
You can install the package via composer:
composer require illuma-law/laravel-wayfinder-forge --dev
Publish the config file:
php artisan vendor:publish --tag="laravel-wayfinder-forge-config"
Configuration
The published config/wayfinder-forge.php allows you to customize the output behavior:
return [ /** * The output path for the generated TypeScript SDK file. */ 'output_path' => resource_path('js/api/sdk.ts'), /** * Define which routes should be processed. */ 'routes' => [ // Only include routes matching these prefixes 'include_prefixes' => [ 'api/*', ], // Exclude routes with specific middleware (like internal debug tools) 'exclude_middlewares' => [ 'debugbar', ], ], /** * The HTTP client template to use for the generated SDK. * Supported: 'axios', 'fetch', 'inertia' */ 'client' => 'axios', /** * Enable support for spatie/laravel-data objects. */ 'use_spatie_data' => true, ];
Usage & Integration
Generate your TypeScript SDK by running the forge command:
php artisan wayfinder:forge
Tip: Add this command to your package.json build scripts so it runs automatically during development.
Example: FormRequests
Laravel Controller & Request
namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class StorePostRequest extends FormRequest { public function rules(): array { return [ 'title' => 'required|string|max:255', 'content' => 'required|string', 'is_published' => 'boolean', // Optional by default unless 'required' is present ]; } } // routes/api.php Route::post('api/posts', [PostController::class, 'store'])->name('posts.store');
Generated TypeScript SDK (resources/js/api/sdk.ts)
export interface ApiPostsRequest { title: string; content: string; is_published?: boolean; } export const postsStore = (data: ApiPostsRequest) => { return axios.post(`/api/posts`, data); };
Example: Spatie Laravel Data
If you are using spatie/laravel-data to type-hint your controllers instead of FormRequests, Forge handles that automatically.
Laravel Controller & Data Object
namespace App\Data; use Spatie\LaravelData\Data; class UserData extends Data { public string $name; public ?int $age; } // routes/api.php Route::post('api/users', function (UserData $userData) { // ... });
Generated TypeScript SDK
export interface UserData { name: string; age?: number; } export const apiUsers = (data: UserData) => { return axios.post(`/api/users`, data); };
Testing
Run the package tests:
composer test
License
The MIT License (MIT). Please see License File for more information.
illuma-law/laravel-wayfinder-forge 适用场景与选型建议
illuma-law/laravel-wayfinder-forge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「typescript」 「wayfinder」 「sdk-generator」 「illuma-law」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 illuma-law/laravel-wayfinder-forge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 illuma-law/laravel-wayfinder-forge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 illuma-law/laravel-wayfinder-forge 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generate typescript rpc from php
Transforms Laravel Models to Typescript Interfaces/Types
Configurable navigation package for Laravel with breadcrumb and tree generation
Attribute-based route generation for Laravel - automatically generate routes from controller method attributes
Minimal Laravel authentication scaffolding with Vue, Vite, Typescript and Tailwind.
End-to-end type-safe APIs for Laravel. Like tRPC, but for Laravel + TypeScript.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-20