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

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

based/laravel-typescript
========================

Transform Laravel models into TypeScript interfaces

v0.0.4(2y ago)399154.8k↓24.3%55[10 issues](https://github.com/lepikhinb/laravel-typescript/issues)[6 PRs](https://github.com/lepikhinb/laravel-typescript/pulls)MITPHPPHP ^8.0

Since Jul 25Pushed 2y ago5 watchersCompare

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

READMEChangelog (1)Dependencies (8)Versions (5)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 interfaces 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 interface:

```
declare namespace App.Models {
    export interface 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/models.d.ts'),

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

Usage
-----

[](#usage)

Generate TypeScript interfaces.

```
php artisan typescript:generate
```

Example usage with Vue 3:

```
import { defineComponent, PropType } from "vue";

export default defineComponent({
    props: {
        product: {
            type: Object as PropType,
            required: true,
        },
    },
}
```

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

39

—

LowBetter than 84% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity53

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78% 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 ~236 days

Total

4

Last Release

1069d ago

### Community

Maintainers

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

---

Top Contributors

[![lepikhinb](https://avatars.githubusercontent.com/u/17538801?v=4)](https://github.com/lepikhinb "lepikhinb (39 commits)")[![media253](https://avatars.githubusercontent.com/u/28750663?v=4)](https://github.com/media253 "media253 (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 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)")[![chancezeus](https://avatars.githubusercontent.com/u/2089196?v=4)](https://github.com/chancezeus "chancezeus (1 commits)")[![xyNNN](https://avatars.githubusercontent.com/u/1929750?v=4)](https://github.com/xyNNN "xyNNN (1 commits)")[![ekvedaras](https://avatars.githubusercontent.com/u/3586184?v=4)](https://github.com/ekvedaras "ekvedaras (1 commits)")[![jf908](https://avatars.githubusercontent.com/u/2487520?v=4)](https://github.com/jf908 "jf908 (1 commits)")

---

Tags

laraveltypescript

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

327482.0k25](/packages/codewithdennis-filament-select-tree)[nativephp/desktop

NativePHP for Desktop

37833.6k8](/packages/nativephp-desktop)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124581.3k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[hydrat/filament-table-layout-toggle

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

63105.4k2](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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