PHPackages                             toniel/laravel-enum-to-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. toniel/laravel-enum-to-typescript

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

toniel/laravel-enum-to-typescript
=================================

A Laravel package to convert PHP enums to TypeScript.

v0.1.0(3mo ago)079MITPHPPHP ^8.2

Since Feb 7Pushed 3mo agoCompare

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

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

Laravel Enum to TypeScript
==========================

[](#laravel-enum-to-typescript)

[![Latest Version on Packagist](https://camo.githubusercontent.com/48fb192f2fc0292c9fc108045c4858b38630c0c46e4fafa5cd3e49e1b255299d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6e69656c2f6c61726176656c2d656e756d2d746f2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/toniel/laravel-enum-to-typescript)[![Total Downloads](https://camo.githubusercontent.com/8893d24f7d50c9b9dc7a91b36bd91e2f3a8da85cf88b059a3b8df7799fdd9caa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6e69656c2f6c61726176656c2d656e756d2d746f2d747970657363726970742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/toniel/laravel-enum-to-typescript)

A simple Laravel package to convert your PHP enums into TypeScript enums, helping you maintain type safety between your backend and frontend.

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

[](#installation)

You can install the package via composer:

```
composer require toniel/laravel-enum-to-typescript
```

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

[](#configuration)

To publish the configuration file, run the following command:

```
php artisan vendor:publish --provider="Toniel\LaravelEnumToTypeScript\LaravelEnumToTypeScriptServiceProvider" --tag="config"
```

This will create a `config/enum-to-typescript.php` file in your application's config directory. Here, you can customize the default paths and behavior of the command.

```
// config/enum-to-typescript.php

return [
    // The directory where your PHP enums are located.
    'source_dir' => 'app/Enums',

    // The directory where the generated TypeScript enums will be placed.
    'dest_dir' => 'resources/ts/Enums',

    // The case for the generated TypeScript enum filenames.
    // Supported values: "PascalCase", "kebab-case".
    'filename_case' => 'PascalCase',

    // Defines how the TypeScript enums are generated.
    // Supported values: "multiple_files", "single_file".
    'output_strategy' => 'multiple_files',

    // When using the "single_file" output strategy, this will be the name
    // of the generated TypeScript file (without the .ts extension).
    'single_file_name' => 'enums',
];
```

Usage
-----

[](#usage)

To convert your PHP enums to TypeScript, run the following artisan command:

```
php artisan typescript:transform-enum
```

The command will scan the `source_dir` for PHP enums and generate the corresponding TypeScript enums in the `dest_dir`.

### Options

[](#options)

You can override the default configuration by passing options to the command:

- `--source`: Specify the source directory for PHP enums.

    ```
    php artisan typescript:transform-enum --source="app/CustomEnums"
    ```
- `--dest`: Specify the destination directory for TypeScript enums.

    ```
    php artisan typescript:transform-enum --dest="resources/js/types"
    ```
- `--filename-case`: Specify the case for the generated filenames (`PascalCase` or `kebab-case`).

    ```
    php artisan typescript:transform-enum --filename-case=kebab-case
    ```
- `--strategy`: Specify the output strategy (`single_file` or `multiple_files`).

    ```
    php artisan typescript:transform-enum --strategy=single_file
    ```

### Example

[](#example)

Given a PHP enum:

```
// app/Enums/UserRole.php

namespace App\Enums;

enum UserRole: string
{
    case ADMIN = 'admin';
    case USER = 'user';
}
```

Running the command will generate the following TypeScript enum:

**Multiple Files Strategy (default)**

A new file `resources/ts/Enums/UserRole.ts` will be created:

```
export enum UserRole {
  ADMIN = 'admin',
  USER = 'user',
}
```

**Single File Strategy**

A single file `resources/ts/Enums/enums.ts` (or your configured `single_file_name`) will be created containing all enums:

```
export enum UserRole {
  ADMIN = 'admin',
  USER = 'user',
}

// ... other enums ...
```

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance82

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

94d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/30f3dcba5ea96072a20acd7d6b3043abc5b560cee5d8f3d4cf1f9894dc8b9054?d=identicon)[toniel](/maintainers/toniel)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/toniel-laravel-enum-to-typescript/health.svg)

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

###  Alternatives

[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)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[napp/xray-laravel

AWS X-Ray for Laravel applications.

61407.3k](/packages/napp-xray-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)

PHPackages © 2026

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