spatie/laravel-typescript-transformer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

spatie/laravel-typescript-transformer

最新稳定版本:2.5.2

Composer 安装命令:

composer require spatie/laravel-typescript-transformer

包简介

Transform your PHP structures to TypeScript types

README 文档

README

Logo for laravel-typescript-transformer

Transform PHP types to TypeScript

Latest Version on Packagist GitHub Tests Action Status Styling Psalm Total Downloads

Always wanted type safety within PHP and TypeScript without duplicating a lot of code? Then you will like this package! Let's say you have an enum:

class Languages extends Enum
{
    const TYPESCRIPT = 'typescript';
    const PHP = 'php';
}

Wouldn't it be cool if you could have an automatically generated TypeScript definition like this:

export type Languages = 'typescript' | 'php';

This package will automatically generate such definitions for you, the only thing you have to do is adding this annotation:

/** @typescript **/
class Languages extends Enum
{
    const TYPESCRIPT = 'typescript';
    const PHP = 'php';
}

You can even take it a bit further and generate TypeScript from classes:

/** @typescript */
class User
{
    public int $id;

    public string $name;

    public ?string $address;
}

This will be transformed to:

export type User = {
    id: number;
    name: string;
    address: string | null;
}

Want to know more? You can find the documentation here.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 5.05M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 345
  • 点击次数: 1
  • 依赖项目数: 43
  • 推荐数: 3

GitHub 信息

  • Stars: 345
  • Watchers: 5
  • Forks: 25
  • 开发语言: PHP

其他信息

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