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

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

basedcollective/laravel-typescript
==================================

Transform Laravel models into TypeScript interfaces

v0.0.5(3mo ago)493↓33.3%MITPHPPHP ^8.1CI passing

Since Feb 1Pushed 3mo agoCompare

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

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

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

[](#laravel-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6f970bd63105287b018e7eb6d34ac01d2aca8ca274e764d576f3521fcdf9432b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6261736564636f6c6c6563746976652f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/basedcollective/laravel-typescript)[![GitHub Tests Action Status](https://camo.githubusercontent.com/73c10292058526926f176acddd1dc8aad62205146c785b3f4e18fafe26505937/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6261736564636f6c6c6563746976652f6c61726176656c2d747970657363726970742f72756e2d74657374732e796d6c3f6c6162656c3d7465737473266272616e63683d6d61696e)](https://github.com/BasedCollective/laravel-typescript/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3b964f8024d1298dea3a3c07683403dcd59b0e33def6c346916d10e3dc1f9ab9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6261736564636f6c6c6563746976652f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/basedcollective/laravel-typescript)

Note

This is an up-to-date, maintained fork of the abandoned [laravel-typescript](https://github.com/lepikhinb/laravel-typescript) package.

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

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

[](#installation)

**Laravel 10+ and PHP 8.1 are required.**

You can install the package via composer:

```
composer require basedcollective/laravel-typescript
```

Usage
-----

[](#usage)

Generate TypeScript interfaces:

```
php artisan typescript:generate
```

Example usage with Vue 3:

```

defineProps();

    {{ product.name }}
    Price: ${{ product.price }}

```

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

[](#configuration)

Optionally, you can publish the config file:

```
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,
];
```

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

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [Ostap Brehin](https://github.com/osbre)
- [Boris Lepikhin](https://github.com/lepikhinb) (original author)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance86

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

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

96d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23292709?v=4)[Ostap Brehin](/maintainers/osbre)[@osbre](https://github.com/osbre)

---

Top Contributors

[![lepikhinb](https://avatars.githubusercontent.com/u/17538801?v=4)](https://github.com/lepikhinb "lepikhinb (39 commits)")[![osbre](https://avatars.githubusercontent.com/u/23292709?v=4)](https://github.com/osbre "osbre (10 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)")[![PatrickRose](https://avatars.githubusercontent.com/u/1681612?v=4)](https://github.com/PatrickRose "PatrickRose (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)")[![Litiano](https://avatars.githubusercontent.com/u/8152537?v=4)](https://github.com/Litiano "Litiano (1 commits)")

---

Tags

laraveltypescript

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M82](/packages/spatie-laravel-health)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58109.4k](/packages/laracraft-tech-laravel-useful-additions)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

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