PHPackages                             levintoo/laravel-enum-exporter - 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. levintoo/laravel-enum-exporter

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

levintoo/laravel-enum-exporter
==============================

Laravel dev-only package to export PHP enums to TypeScript

0.1.0(10mo ago)047MITPHPPHP ^8.1CI passing

Since Jul 11Pushed 10mo agoCompare

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

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

Laravel Enum Exporter
=====================

[](#laravel-enum-exporter)

[![Tests](https://github.com/levintoo/laravel-enum-exporter/actions/workflows/tests.yml/badge.svg)](https://github.com/levintoo/laravel-enum-exporter/actions/workflows/tests.yml)[![Latest Unstable Version](https://camo.githubusercontent.com/9308c20ca96a4ce8c7ae07fc972134b0035625dcb13efcd645ff48a8517428d9/687474703a2f2f706f7365722e707567782e6f72672f6c6576696e746f6f2f6c61726176656c2d656e756d2d6578706f727465722f762f756e737461626c65)](https://packagist.org/packages/levintoo/laravel-enum-exporter)[![License](https://camo.githubusercontent.com/f7c701832e4a31233517da58ff8f9c56e9c383e9465295293accfc6bc52cf543/687474703a2f2f706f7365722e707567782e6f72672f6c6576696e746f6f2f6c61726176656c2d656e756d2d6578706f727465722f6c6963656e7365)](https://packagist.org/packages/levintoo/laravel-enum-exporter)

Effortlessly sync PHP enums to TypeScript for type-safe frontend integration. This dev-only Laravel package exports your PHP enums into TypeScript files under `resources/js/enums`, letting you use the same enum definitions on the frontend as your server.

### 📦 Installation

[](#-installation)

```
composer require levintoo/laravel-enum-exporter --dev
```

### 🚀 Usage

[](#-usage)

**Export a single enum (TypeScript):**

```
php artisan export:enum Role
# or
php artisan export:enum app/Enums/Role.php
```

**Export all enums in `app/Enums` (TypeScript):**

```
php artisan export:enum --all
```

**Export enums as JavaScript workarounds (instead of TypeScript):**

```
php artisan export:enum Role --js
# or
php artisan export:enum --all --js
```

🗂 **Output Path**TypeScript files are generated in:

- **TypeScript:**`resources/js/enums/{kebab-case-enum}.ts`
- **JavaScript:**`resources/js/enums/{kebab-case-enum}.js`

### 📝 Example

[](#-example)

Given a PHP enum:

```
/* app/Enums/UserStatus.php */
enum UserStatus: string
{
    case Active = 'active';
    case Inactive = 'inactive';
    case Pending = 'pending';
}
```

The following TypeScript file will be generated:

```
/* resources/js/enums/user-status.ts */
export enum UserStatus {
    Active = 'active',
    Inactive = 'inactive',
    Pending = 'pending',
}
```

or The following Javascript file will be generated:

```
/* resources/js/enums/user-status.js */
const UserStatus = {
    Active: { name: 'Active', value: 'active' },
    Inactive: { name: 'Inactive', value: 'inactive' },
    Pending: { name: 'Pending', value: 'pending' },

    cases() {
        return Object.values(this).filter(e => e?.value !== undefined);
    },

    from(slug) {
        return this.cases().find(
            e => e.name.toLowerCase() === slug
        ) ?? null;
    },

    get(value) {
        return this.cases().find(
            e => e.value === value
        ) ?? null;
    }
};

export default UserStatus;
```

### ⚠️ Current Status

[](#️-current-status)

> This package is **pre-alpha**: APIs and behavior are actively evolving and may change without notice.

### 🛠 Future Plans

[](#-future-plans)

FeatureStatusPublish to Packagist⏳ PlannedSupport enums with methods/properties⏳ PlannedAdd option to overwrite existing files⏳ PlannedAllow custom output paths for TS files⏳ PlannedSupport multiple case styles (kebab, Pascal)⏳ PlannedSupport JS enum workarounds⏳ Planned

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance55

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

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

302d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23132a4c3a6cf3be2b5a0cd7b5ad9ad86199a5cbf6e9c2a23578ddfe100583b3?d=identicon)[levintoo](/maintainers/levintoo)

---

Top Contributors

[![levintoo](https://avatars.githubusercontent.com/u/44953808?v=4)](https://github.com/levintoo "levintoo (8 commits)")

---

Tags

laravelpackage

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/levintoo-laravel-enum-exporter/health.svg)

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

###  Alternatives

[bdelespierre/underscore

Underscore.js port in PHP

6943.7k1](/packages/bdelespierre-underscore)[setono/cron-expression-bundle

Symfony bundle that integrates dragonmantank/cron-expression

25191.4k3](/packages/setono-cron-expression-bundle)[hiqdev/hidev

Automation tool mixed with code generator for easier continuous development

3229.4k28](/packages/hiqdev-hidev)[hiqdev/yii2-collection

Collection library for Yii2

1044.8k6](/packages/hiqdev-yii2-collection)

PHPackages © 2026

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