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

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

lanre/laravel-typescript
========================

Transform Laravel models into TypeScript interfaces

012PHPCI failing

Since Jan 13Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

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

[](#laravel-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/90b01e5895c11fe23399b4f55177a6878372c4010941c93c6132de93f8ad4b0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c616e72652f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lanre/laravel-typescript)[![GitHub Tests Action Status](https://camo.githubusercontent.com/efc21c523a59de4bd75d2cd8ed53d2d5e830bbb7b6f623fa7245795369732346/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6f706c616e72652f6c61726176656c2d747970657363726970742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/oplanre/laravel-typescript/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b7770f5af8af0d8b9db0677075a4cd307a3d87fc36cda14fb16027eedf4f900b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c616e72652f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lanre/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="Lame\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)

- [Lanre Ajao](https://github.com/oplanre)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance53

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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/481db45e6eedb1cc562223508f3ca9d1b6766ede1afe0f154657ce12ee8d7b5a?d=identicon)[lanre](/maintainers/lanre)

---

Top Contributors

[![oplanre](https://avatars.githubusercontent.com/u/113967437?v=4)](https://github.com/oplanre "oplanre (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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