定制 pentacore/laravel-typefinder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pentacore/laravel-typefinder

Composer 安装命令:

composer require pentacore/laravel-typefinder

包简介

Auto-generate TypeScript type definitions from Laravel Models, Enums, Casts, and Requests.

README 文档

README

Tests codecov License semantic-release

Packagist Version Packagist Downloads NPM Version NPM Downloads

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

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.

统计信息

  • 总下载量: 596
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固