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

ActiveLibrary

gabrielmpetrescu/laravel-typescript
===================================

Transform Laravel models into TypeScript interfaces

05.9k↑25%PHP

Since Feb 13Pushed 3mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/49dd2b3492299baec67d72bde81ce37629e75b6199dac554133848da482faf44/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6761627269656c6d70657472657363752f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](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/cf7cf20f12954cb1b260b665666712129ae45591369ae882971dfdb5ef2ca625/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6761627269656c6d70657472657363752f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](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.1+ are required.** This package supports Laravel 8, 9, 10, 11, and 12. You can install the package via composer:

```
composer require gabrielmpetrescu/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

27

—

LowBetter than 49% of packages

Maintenance55

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/33794bbbfb392b7b02ff32db740368e95d2ec043c950acc844eeeeddb4835cb6?d=identicon)[gabrielmpetrescu](/maintainers/gabrielmpetrescu)

---

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)")[![gabrielpetrescu](https://avatars.githubusercontent.com/u/33344024?v=4)](https://github.com/gabrielpetrescu "gabrielpetrescu (2 commits)")[![gabrielmpetrescu](https://avatars.githubusercontent.com/u/148048698?v=4)](https://github.com/gabrielmpetrescu "gabrielmpetrescu (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 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)")[![robmeijerink](https://avatars.githubusercontent.com/u/14540290?v=4)](https://github.com/robmeijerink "robmeijerink (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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