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

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

wovosoft/laravel-typescript
===========================

Transforms Laravel Models to Typescript Interfaces/Types

v1.1.2(7mo ago)132.2k2[1 PRs](https://github.com/wovosoft/laravel-typescript/pulls)MITPHP

Since Jul 3Pushed 7mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (19)Used By (0)

Laravel Typescript
==================

[](#laravel-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8eda72622e7ee234b926211da2f65c414801e68b74726a331d20075b3c631de2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f766f736f66742f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wovosoft/laravel-typescript)[![Total Downloads](https://camo.githubusercontent.com/e4af5933d5f4772cc6b873a4613b5b2ab3937cf3ed3749e913f6a0db68e67500/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f766f736f66742f6c61726176656c2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wovosoft/laravel-typescript)[![Build Status](https://camo.githubusercontent.com/1399fd03a48ca0184e666056e39f275011327b5c1888288378c1314666f59cb5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f776f766f736f66742f6c61726176656c2d747970657363726970742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/wovosoft/laravel-typescript)[![StyleCI](https://camo.githubusercontent.com/7a5deddb7d9eadf125d225d59ed60aee3dfd68064200dccb324dfc446037864d/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3636313633373733382f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/661637738)

Transforms Laravel Models to Typescript Interfaces/Types

Precautions
-----------

[](#precautions)

This packages instantiates Models to retrieve it's casts, attributes, relations in some cases. So, if your models have some sensitive actions inside \_\_constructor method, please be aware of using this package.

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

[](#installation)

Via Composer

```
composer require --dev wovosoft/laravel-typescript
```

Publish Configuration
---------------------

[](#publish-configuration)

Run the command given below. This will publish `laravel-typescript.php` config file.

```
php artisan vendor:publish --provider="Wovosoft\LaravelTypescript\LaravelTypescriptServiceProvider"
```

Configure the configurations

```
return [
    'output_path'       => resource_path('js/types/models.d.ts'),
    'source_dir'        => app_path('Models'),
    /**
     * Custom attributes should have return types defined.
     * But if it is not, then the return type should be this type.
     * And this value should be php supported return types.
     * like primitive types or any other classes
     */
    "custom_attributes" => [
        "fallback_return_type" => "string"
    ]
];
```

Usage
-----

[](#usage)

Run the command given below to generate typescript types.

```
php artisan laravel-typescript:transform
```

Generated contents will be written in configured location.

Advanced Usage
--------------

[](#advanced-usage)

Sometimes Models can be stored in different locations, like in some packages, some directories etc., in that case, please check the source of [./src/LaravelTypescript.php](https://github.com/wovosoft/laravel-typescript/blob/master/src/LaravelTypescript.php)

You can just instantiate this class, and generate types for models in some other directories.

```
use Wovosoft\LaravelTypescript\Facades\LaravelTypescript;

$dirs = [
    "models"               => app_path("Models"),
    "hrmPerson"            => base_path("packages/wovosoft/hrms-person/src/Models"),
];

foreach ($dirs as $name => $dir) {
    LaravelTypescript::generate(
        sourceDir : $dir,
        outputPath: resource_path("js/types/$name.d.ts")
    );

    echo "Generated $name.d.ts";
}
```

Note on New Model Attributes
----------------------------

[](#note-on-new-model-attributes)

For new Model Attributes, return type of the Closure function should be defined, otherwise, it will generate value of `config('laravel-typescript.custom_attributes.fallback_return_type')` type for the related property.

```
use \Illuminate\Database\Eloquent\Model;
use \Illuminate\Database\Eloquent\Casts\Attribute;

class User extends Model{
    public function isActive() : Attribute
    {
        return Attribute::get(fn(): bool =>$this->status==='active');
    }

    public function getIsInactiveAttribute():bool
    {
        return $this->status==="inactive";
    }
}
```

Change log
----------

[](#change-log)

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

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please create issues in [Issues Tracker](https://github.com/wovosoft/laravel-typescript/issues)

Credits
-------

[](#credits)

- [Narayan Adhikary](https://github.com/wovosoft)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance64

Regular maintenance activity

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.5% 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 ~69 days

Recently: every ~154 days

Total

13

Last Release

221d ago

PHP version history (3 changes)v1.0.0PHP ^8.1

v1.0.3PHP &gt;=8.1

v1.0.9PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![wovosoft](https://avatars.githubusercontent.com/u/56657054?v=4)](https://github.com/wovosoft "wovosoft (32 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (5 commits)")

---

Tags

laraveltypescript-transformerTypescript InterfacesTypescript Typesphp to typescript

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[keepsuit/laravel-temporal

Laravel temporal.io

4875.0k](/packages/keepsuit-laravel-temporal)[soyhuce/next-ide-helper

Laravel ide helper rebuilt under steroids

4756.2k3](/packages/soyhuce-next-ide-helper)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)

PHPackages © 2026

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