PHPackages                             brunoscode/laravel-ts-annotations - 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. brunoscode/laravel-ts-annotations

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

brunoscode/laravel-ts-annotations
=================================

Write raw TypeScript types in PHP attributes and generate .ts files with an Artisan command.

v0.3.0(1mo ago)0381↓50%MITPHPPHP ^8.2CI failing

Since May 10Pushed 2mo agoCompare

[ Source](https://github.com/BrunosCode/LaravelTsAnnotations)[ Packagist](https://packagist.org/packages/brunoscode/laravel-ts-annotations)[ RSS](/packages/brunoscode-laravel-ts-annotations/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (8)Versions (9)Used By (0)

Laravel TS Annotations
======================

[](#laravel-ts-annotations)

> Generate TypeScript types from PHP attributes and emit them to `.ts` files with a single Artisan command — for Laravel apps with a typed frontend.

[![Latest Version on Packagist](https://camo.githubusercontent.com/f6b783d5a388aa690514c08d355f295ce23165556fba4cc110c882a3039999f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272756e6f73636f64652f6c61726176656c2d74732d616e6e6f746174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brunoscode/laravel-ts-annotations)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3b76c674bc546d940a51b3500d1a15479d055c676137281324cf58c13e84865b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4272756e6f73436f64652f4c61726176656c5473416e6e6f746174696f6e732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/BrunosCode/LaravelTsAnnotations/actions?query=workflow%3Atests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/85806e4aa625e4af7b47c73ddc3449804d3b4e0741dd7ae37c6264878f192983/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4272756e6f73436f64652f4c61726176656c5473416e6e6f746174696f6e732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/BrunosCode/LaravelTsAnnotations/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8a188107c29abfaadfc79406880549397cd757e69cba084b4d92e8599ab71a0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272756e6f73636f64652f6c61726176656c2d74732d616e6e6f746174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brunoscode/laravel-ts-annotations)[![License](https://camo.githubusercontent.com/633b700ca11448558f813cc8f0f9c785ddce905b61612978df880d41c2c90de9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6272756e6f73636f64652f6c61726176656c2d74732d616e6e6f746174696f6e732e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Keeping PHP and a typed frontend in sync usually means one of two compromises: **infer** TypeScript from PHP types (and lose union types, template literals, and generics), or route everything through a Swagger/OpenAPI intermediary (indirect and verbose). This package skips both — you attach the TypeScript you want, in PHP, and generate `.ts` with one command. Three annotation styles give you three levels of control:

- `#[TS]` — write **real TypeScript** verbatim when you need unions, templates, or generics
- `#[TSType]` — **auto-infer** from PHP property types for simple DTOs and data classes
- `#[TSEnum]` — **auto-generate** TypeScript enums from PHP backed or unit enums

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Resources, Collections, and Inertia](#resources-collections-and-inertia)
- [Ordering in the Output File](#ordering-in-the-output-file)
- [File Preservation](#file-preservation)
- [Laravel Boost](#laravel-boost)
- [Configuration](#configuration)
- [Roadmap](#roadmap)
- [Testing](#testing)
- [Changelog](#changelog)
- [Credits](#credits)
- [Contributing](#contributing)
- [License](#license)

Requirements
------------

[](#requirements)

LaravelPHP13.x8.3, 8.4, 8.512.x8.2, 8.3, 8.4, 8.5Installation
------------

[](#installation)

```
composer require brunoscode/laravel-ts-annotations
```

Publish the config file:

```
php artisan vendor:publish --tag=ts-annotations-config
```

Quick Start
-----------

[](#quick-start)

```
// Raw TypeScript — full control
#[TS( [
        app_path('Http'),       // covers Resources, Controllers, Requests, Middleware
        app_path('Enum'),       // enums annotated with #[TSEnum]
        app_path('Data'),       // DTOs annotated with #[TSType]
    ],

    // Output .ts files. The array key is referenced in the `output` param.
    'outputs' => [
        'default' => [
            'path'    => resource_path('js/types/generated.ts'),
            // Lines written verbatim at the top of the generated section on every run.
            // Useful for shared generics like CollectionResource / PaginatedResource.
            'imports' => [
                'export type CollectionResource = { data: T[] };',
                '',
                'export type PaginatedResource = {',
                '    data: T[];',
                '    total: number;',
                '    per_page: number;',
                '    current_page: number;',
                '    last_page: number;',
                '    from: number | null;',
                '    to: number | null;',
                '    first_page_url: string;',
                '    last_page_url: string;',
                '    next_page_url: string | null;',
                '    prev_page_url: string | null;',
                '    path: string;',
                '};',
            ],
        ],
        // 'admin' => [
        //     'path'    => resource_path('js/types/admin.ts'),
        //     'imports' => [],
        // ],
    ],

    // Comment markers that delimit the generated section.
    // Everything outside the markers is preserved on re-generation.
    'markers' => [
        'start' => '// [ts-annotations:start]',
        'end'   => '// [ts-annotations:end]',
    ],

];
```

Roadmap
-------

[](#roadmap)

Planned, not yet shipped:

- `--watch` flag for automatic regeneration on file change

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for what has changed recently.

Credits
-------

[](#credits)

- [BrunosCode](https://github.com/BrunosCode)
- [All Contributors](https://github.com/BrunosCode/LaravelTsAnnotations/graphs/contributors)

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to discuss what you would like to change.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance89

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~6 days

Total

7

Last Release

38d ago

PHP version history (2 changes)v0.1.0PHP ^8.1

v0.3.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![BrunosCode](https://avatars.githubusercontent.com/u/78606186?v=4)](https://github.com/BrunosCode "BrunosCode (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brunoscode-laravel-ts-annotations/health.svg)

```
[![Health](https://phpackages.com/badges/brunoscode-laravel-ts-annotations/health.svg)](https://phpackages.com/packages/brunoscode-laravel-ts-annotations)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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