PHPackages                             alexstewartja/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. [Database &amp; ORM](/categories/database)
4. /
5. alexstewartja/laravel-typescript

ActiveLibrary[Database &amp; ORM](/categories/database)

alexstewartja/laravel-typescript
================================

Generate TypeScript interfaces/definitions from Eloquent models

0.1.0(1y ago)14MITPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4CI failing

Since Apr 2Pushed 1y agoCompare

[ Source](https://github.com/alexstewartja/laravel-typescript)[ Packagist](https://packagist.org/packages/alexstewartja/laravel-typescript)[ Docs](https://github.com/alexstewartja/laravel-typescript)[ Fund](https://www.buymeacoffee.com/alexstewartja)[ GitHub Sponsors](https://github.com/alexstewartja)[ RSS](/packages/alexstewartja-laravel-typescript/feed)WikiDiscussions main Synced today

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

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

[](#laravel-typescript)

[![Latest Stable Version](https://camo.githubusercontent.com/3d83068a01c23b1a73e9d7dd78d38cfc9216a80e30e2181811237f23e6e7a765/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f76)](https://packagist.org/packages/alexstewartja/laravel-typescript)[![Total Downloads](https://camo.githubusercontent.com/f7e43095a621146abf62cc6a2514cf7dff310ad3d2f5bdf895912ff77f8c689d/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f646f776e6c6f616473)](https://packagist.org/packages/alexstewartja/laravel-typescript)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4877f670b7a9e2a1fc93be495abc18c17915d78ae5667aff27bedaf9bdce7b8e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f7068702d63732d66697865722e796d6c3f6c6162656c3d636f64652532307374796c65)](https://github.com/alexstewartja/laravel-typescript/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![License](https://camo.githubusercontent.com/d9c947689bfc5861d627b446a2c4f415ace765db8233952f5500cade9d09174e/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f6c6963656e7365)](https://packagist.org/packages/alexstewartja/laravel-typescript)

[![PHP Versions Supported](https://camo.githubusercontent.com/60526b4b552f1512cc423966c6eda9df758b05371c3f65f85f548c653cb61ff8/687474703a2f2f706f7365722e707567782e6f72672f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f726571756972652f706870)](https://packagist.org/packages/alexstewartja/laravel-typescript)[![Laravel Versions Supported](https://camo.githubusercontent.com/4ac6ebd50b3884f3174ab27a4b3d04f5779cbe6daa8b033a67af57f7fd80d728/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f616c6578737465776172746a612f6c61726176656c2d747970657363726970742f696c6c756d696e6174652f636f6e7472616374733f6c6162656c3d6c61726176656c)](https://packagist.org/packages/alexstewartja/laravel-typescript)

[![Buy Me A Coffee](https://camo.githubusercontent.com/3ce5cc1c728bf8e0be5bbd132e9d5413d3a922cecfc3381decdcc82c5f66da9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4275795f4d652d415f436f666665652d6f72616e67653f6c6f676f3d6275792d6d652d612d636f66666565)](https://buymeacoffee.com/alexstewartja)

A Laravel package which allows you to quickly generate TypeScript interfaces/definitions for your Eloquent models.

Features
--------

[](#features)

- ✅ Database columns
- ✅ Model relations
- ✅ Model accessors
- ⏳ Model casts
- ⏳ Inherited relations (Traits/Mixins, etc.)

DBMS Compatibility (Laravel 11+)
--------------------------------

[](#dbms-compatibility-laravel-11)

- ✅ pgsql (PostgresSQL)
- ⏳ mysql (MySQL)
- ⏳ mariadb (MariaDB)
- ⏳ sqlsrv (Microsoft SQL Server)
- ⏳ sqlite (SQLite)

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

[](#installation)

You can install the package via composer:

```
composer require alexstewartja/laravel-typescript
```

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

[](#configuration)

Publish the config file (`config/laravel-typescript.php`) with:

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

Usage
-----

[](#usage)

Generate TypeScript interfaces for your Eloquent Models:

```
php artisan laravel-typescript:generate
```

### Example

[](#example)

#### Eloquent Model

[](#eloquent-model)

As an example, the following Product model is defined in an eCommerce app:

```
class Product extends Model
{
    protected $fillable = [
        'name',
        'price',
    ];

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

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

#### TypeScript Interface

[](#typescript-interface)

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;
    }
}
```

#### TS Interface Usage

[](#ts-interface-usage)

This is an example usage with Vue 3:

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

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

And another Vue 3 example for InertiaJS:

```
interface CartPageProps {
    products?: Array | null;
    coupon_code?: string;
}

defineProps();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

A [Lando](https://lando.dev/) file is included in the repo to get up and running quickly:

```
lando start
```

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for more details.

Security
--------

[](#security)

Please see [SECURITY](.github/SECURITY.md) for more details.

Credits
-------

[](#credits)

- [Alex Stewart](https://github.com/alexstewartja)
- [Boris Lepikhin](https://github.com/lepikhinb) - For developing [the foundation](https://github.com/lepikhinb/laravel-typescript) on which this package is "based" 🥁
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance43

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

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

458d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/082480752bcdbb416813f3ac88ee08dd199e7b05f535f033128e81a33c651be8?d=identicon)[alexstewartja](/maintainers/alexstewartja)

---

Top Contributors

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

---

Tags

eloquent-modelslaraveltypescripttypescript-definitionslaraveleloquentinterfacetypescripttypes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[giacomomasseron/laravel-models-generator

Generate Laravel models from an existing database

557.6k](/packages/giacomomasseron-laravel-models-generator)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

213421.2k2](/packages/wnx-laravel-backup-restore)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17558.6k](/packages/lacodix-laravel-model-filter)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)

PHPackages © 2026

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