PHPackages                             sedlatschek/laravel-typescript-writer - 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. sedlatschek/laravel-typescript-writer

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

sedlatschek/laravel-typescript-writer
=====================================

This is my package laravel-typescript-writer

v1.0.0-beta.8(2y ago)03.0k[2 PRs](https://github.com/sedlatschek/laravel-typescript-writer/pulls)MITPHPPHP ^8.1

Since Jun 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/sedlatschek/laravel-typescript-writer)[ Packagist](https://packagist.org/packages/sedlatschek/laravel-typescript-writer)[ Docs](https://github.com/sedlatschek/laravel-typescript-writer)[ RSS](/packages/sedlatschek-laravel-typescript-writer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (12)Versions (11)Used By (0)

laravel-typescript-writer
=========================

[](#laravel-typescript-writer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c4cc8d890683588fb7a56548c68785fa17b5434a826c6a0e415ac6bc9fae0e28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365646c6174736368656b2f6c61726176656c2d747970657363726970742d7772697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sedlatschek/laravel-typescript-writer)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b5db4a99c50c9f570db96dc5e4cceb165466317ec235a6490fa38d8d3d5d511b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7365646c6174736368656b2f6c61726176656c2d747970657363726970742d7772697465722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sedlatschek/laravel-typescript-writer/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8c1b0a9821abe664a6a42ddbbfacd94f814a8c0c94b08cf42006517e106fa663/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7365646c6174736368656b2f6c61726176656c2d747970657363726970742d7772697465722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sedlatschek/laravel-typescript-writer/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0d57d0224164c3068e8d81348de1f8dc9b08e12ef343cce7a0974d260f3385ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7365646c6174736368656b2f6c61726176656c2d747970657363726970742d7772697465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sedlatschek/laravel-typescript-writer)

Write typescript data out of laravel. Does not generate interfaces. Eg.:

```
$simon = [
    'name' => 'Simon'
]
```

will turn into

```
export const simon: Person = {
    name: "Simon"
}
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require --dev sedlatschek/laravel-typescript-writer
```

You should publish the config file with:

```
php artisan vendor:publish --tag="typescript-writer-config"
```

This is the contents of the published config file:

```
return [
    // The typescript file indentation
    'indentation' => 2,

    // The end-of-line character
    'eol_char' => PHP_EOL,

    // Whether to use single or double quotes for strings
    'single_quote' => true,

    // The files that should be written
    'files' => [
        /*
        new TypescriptFile(__DIR__.'/example.ts', [
            // The contents of the file
            new TypescriptData('Array', 'test', [
                [
                    'id' => 33,
                    'name' => 'test',
                    'active' => true,
                    'languages' => [
                        'German',
                        'English',
                    ],
                ],
            ]),
        ]),
        */
    ],
];
```

Configuration
-------------

[](#configuration)

### Value Replacements

[](#value-replacements)

You can replace given values with hardcoded strings. This can be useful if you have an enum that can be matched with the output values.

```
new TypescriptData(
    'Array',
    'test',
    // the data
    [
        [
            'test' => [
                'flags' => [
                    1,
                    2,
                    3,
                ],
            ],
        ],
    ],
    // the configured replacements
    [
        '*.test.flags' => [
            1 => 'SomeEnum.ABC',
            2 => 'SomeEnum.DEF',
            3 => 'SomeEnum.GHJ',
        ],
    ]),
```

will output

```
export const test: Array = [
  {
    test: {
      flags: [
        SomeEnum.ABC,
        SomeEnum.DEF,
        SomeEnum.GHJ
      ]
    }
  }
];
```

Usage
-----

[](#usage)

```
php artisan typescript-writer
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Simon Sedlatschek](https://github.com/sedlatschek)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~7 days

Recently: every ~12 days

Total

8

Last Release

1029d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b1b2b23323636313426acffaa6e749f0392fd1fc7d845117adb37aa54d817fd?d=identicon)[sedlatschek](/maintainers/sedlatschek)

---

Top Contributors

[![sedlatschek](https://avatars.githubusercontent.com/u/58665536?v=4)](https://github.com/sedlatschek "sedlatschek (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laraveltypescripttssedlatscheklaravel-typescript-writer

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sedlatschek-laravel-typescript-writer/health.svg)

```
[![Health](https://phpackages.com/badges/sedlatschek-laravel-typescript-writer/health.svg)](https://phpackages.com/packages/sedlatschek-laravel-typescript-writer)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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