PHPackages                             kestrelwp/docblock-typescript-transformer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kestrelwp/docblock-typescript-transformer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kestrelwp/docblock-typescript-transformer
=========================================

Transform PHP class DocBlocks to TypeScript types.

1.0.0(3mo ago)09.8k↓25%MITPHPPHP &gt;=7.4 &lt;9.0

Since Feb 9Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/kestrelcommerce/docblock-typescript-transformer)[ Packagist](https://packagist.org/packages/kestrelwp/docblock-typescript-transformer)[ RSS](/packages/kestrelwp-docblock-typescript-transformer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

A package to transform PHP DocBlock class property annotations to TypeScript interfaces.

Provides a transformer for the [Spatie TypeScript Transformer](https://github.com/spatie/typescript-transformer/) package.

Usage
-----

[](#usage)

```
use Kestrel\DocblockTypescriptTransformer\Transformers\ClassDocBlockTransformer;
use Spatie\TypeScriptTransformer\TypeScriptTransformer;
use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig;

$transformerConfig = TypeScriptTransformerConfig::create()
    ->transformers( [
        ClassDocBlockTransformer::create(),
        // ... other transformers
    ] )

$transformer = TypeScriptTransformer::create( $transformerConfig );
```

In a PHP class, use `@property` and the `@typescript` annotations to ensure TypeScript Transformer will generate the correct TypeScript interface.

```
/**
 * Product
 *
 * @property-read int $id product ID
 * @property string $name product name
 * @property string $description description
 * @property Brand $brand
 * @property ProductCategory[] $categories
 * @property array $metadata {@ts-optional}
 * @property array $internal_metadata {@ts-hidden}
 * @property array $brand_map {@ts-record string, Brand}
 * @property float $price {@ts-literal number}
 *
 * @typescript
 */
class Product extends Model {};

#[TypeScript]
enum Brand : string {
	case APPLE = 'apple';
	case SAMSUNG = 'samsung';
	case GOOGLE = 'google';
};

#[TypeScript]
enum ProductCategory: string {
	case PHONE = 'phone';
	case TABLET = 'tablet';
	case LAPTOP = 'laptop';
	case WIDGET = 'widget';
};
```

Will result in this:

```
export type Release = {
	id: number;
	name: string;
	description: string;
	brand: Brand;
	categories: ProductCategory[];
	metadata?: { [key: string]: any };
	brand_map: Record
	price: number
}
export type Brand = "apple" | "samsung" | "google";
export type ProductCategory = "phone" | "tablet" | "laptop" | "widget";
```

Special tags
------------

[](#special-tags)

### `@ts-optional`

[](#ts-optional)

Marks the property as optional in TypeScript.

### `@ts-hidden`

[](#ts-hidden)

Hides the property from the TypeScript interface.

### `@ts-record`

[](#ts-record)

Generates a `Record` type in TypeScript. The first argument is the key type, the second argument is the value type.

### `@ts-literal`

[](#ts-literal)

Generates a literal type in TypeScript. The argument is the literal type, exactly as it should appear in TypeScript.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance81

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e9b056e81620e033a29878d23291b88c19d782c2d3fc13d9c22dcad339be0ca7?d=identicon)[kestrelwp](/maintainers/kestrelwp)

---

Top Contributors

[![ragulka](https://avatars.githubusercontent.com/u/593267?v=4)](https://github.com/ragulka "ragulka (8 commits)")[![unfulvio](https://avatars.githubusercontent.com/u/1227930?v=4)](https://github.com/unfulvio "unfulvio (3 commits)")

### Embed Badge

![Health badge](/badges/kestrelwp-docblock-typescript-transformer/health.svg)

```
[![Health](https://phpackages.com/badges/kestrelwp-docblock-typescript-transformer/health.svg)](https://phpackages.com/packages/kestrelwp-docblock-typescript-transformer)
```

###  Alternatives

[spatie/laravel-typescript-transformer

Transform your PHP structures to TypeScript types

3736.0M45](/packages/spatie-laravel-typescript-transformer)[spatie/laravel-event-sourcing

The easiest way to get started with event sourcing in Laravel

9003.7M26](/packages/spatie-laravel-event-sourcing)[voku/arrayy

Array manipulation library for PHP, called Arrayy!

4875.5M16](/packages/voku-arrayy)[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.4k423.9k30](/packages/mcp-sdk)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12521.4M109](/packages/phpdocumentor-reflection)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
