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

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

alexthekiwi/laravel-typescript
==============================

Transform Laravel models into TypeScript interfaces

0.1.2(2y ago)1177MITPHPPHP ^8.0

Since Feb 22Pushed 2y agoCompare

[ Source](https://github.com/alexthekiwi/laravel-typescript)[ Packagist](https://packagist.org/packages/alexthekiwi/laravel-typescript)[ Docs](https://github.com/alexthekiwi/laravel-typescript)[ GitHub Sponsors](https://github.com/lepikhinb)[ RSS](/packages/alexthekiwi-laravel-typescript/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (4)Used By (0)

Laravel TypeScript
==================

[](#laravel-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/57f0df605ef4f5f7566fb7ef26b0c66cd388607c9be722ef0108fb71c6ba51ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62617365642f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/based/laravel-typescript)[![GitHub Tests Action Status](https://camo.githubusercontent.com/36f1d56ec04c4012d997726dc9fd076928fac5eef0bbc0d43af183b57ae78e34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6c6570696b68696e622f6c61726176656c2d747970657363726970742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/lepikhinb/laravel-typescript/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0173c440cb62d48751d05241621230e882ae29da02d674aca97f61353db637ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62617365642f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/based/laravel-typescript)

The package lets you generate TypeScript types from your Laravel models.

Introduction
------------

[](#introduction)

Say you have a model which has several properties (database columns) and multiple relations.

```
class Product extends Model
{
    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }

    public function features(): HasMany
    {
        return $this->hasMany(Feature::class);
    }
}
```

Laravel TypeScript will generate the following TypeScript type:

```
export type App = {
    Models: {
        Product: {
            id: number;
            category_id: number;
            name: string;
            price: number;
            created_at: string | null;
            updated_at: string | null;
            category?: App.Models.Category | null;
            features?: Array | null;
        }
    };
    ...
}
```

**Laravel TypeScript** supports:

- Database columns
- Model relations
- Model accessors
- Casted attributes

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

[](#installation)

**Laravel 8+ and PHP 8+ are required.**You can install the package via composer:

```
composer require based/laravel-typescript
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Based\TypeScript\TypeScriptServiceProvider" --tag="typescript-config"
```

This is the contents of the published config file:

```
return [
    'generators' => [
        Model::class => ModelGenerator::class,
    ],

    'output' => resource_path('js/types/models.d.ts'),

    // load namespaces from composer's `dev-autoload`
    'autoloadDev' => false,
];
```

Usage
-----

[](#usage)

Generate TypeScript interfaces.

```
php artisan typescript:generate
```

Or the shortcut:

```
php artisan ts:generate
```

Example usage with React:

```
import type { App } from '@/types';

interface Props {
    Product: App['Models']['Product'];
}
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Boris Lepikhin](https://github.com/lepikhinb)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.8% 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 ~89 days

Total

3

Last Release

996d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/02e06d939be026746151b711568e4397d5f9f4d1b6ba54cab3db12f14ccca04c?d=identicon)[alexclark-nz](/maintainers/alexclark-nz)

---

Top Contributors

[![lepikhinb](https://avatars.githubusercontent.com/u/17538801?v=4)](https://github.com/lepikhinb "lepikhinb (34 commits)")[![alexthekiwi](https://avatars.githubusercontent.com/u/38124722?v=4)](https://github.com/alexthekiwi "alexthekiwi (7 commits)")[![media253](https://avatars.githubusercontent.com/u/28750663?v=4)](https://github.com/media253 "media253 (3 commits)")[![chancezeus](https://avatars.githubusercontent.com/u/2089196?v=4)](https://github.com/chancezeus "chancezeus (1 commits)")[![ekvedaras](https://avatars.githubusercontent.com/u/3586184?v=4)](https://github.com/ekvedaras "ekvedaras (1 commits)")[![Litiano](https://avatars.githubusercontent.com/u/8152537?v=4)](https://github.com/Litiano "Litiano (1 commits)")[![robmeijerink](https://avatars.githubusercontent.com/u/14540290?v=4)](https://github.com/robmeijerink "robmeijerink (1 commits)")

---

Tags

laraveltypescript

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
