PHPackages                             wthealth/laravel-enum-transformer - 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. wthealth/laravel-enum-transformer

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

wthealth/laravel-enum-transformer
=================================

1.1.1(3y ago)276.1k—6.2%3[1 PRs](https://github.com/wt-health/laravel-enum-transformer/pulls)MITPHPPHP ^8.0

Since Jan 17Pushed 2y ago3 watchersCompare

[ Source](https://github.com/wt-health/laravel-enum-transformer)[ Packagist](https://packagist.org/packages/wthealth/laravel-enum-transformer)[ Docs](https://github.com/wt-health/laravel-enum-transformer)[ RSS](/packages/wthealth-laravel-enum-transformer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (8)Used By (0)

Laravel Enum Transformer
========================

[](#laravel-enum-transformer)

[![CI Action](https://github.com/wt-health/laravel-enum-transformer/workflows/CI/badge.svg)](https://github.com/wt-health/laravel-enum-transformer/actions?query=workflow%3ACI)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c296e3d15f08152f03f5372280f9df6159fa4dff1420bec3c6168a312c76f9f6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f77742d6865616c74682f6c61726176656c2d656e756d2d7472616e73666f726d65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d617374657226733d30353932376261623139663564386631323465323836306331366339653965313239626665366466)](https://scrutinizer-ci.com/g/wt-health/laravel-enum-transformer/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/fd3e4d4b4404fed0c88217dee4cb1ebf18a5eb2f0e971addac447e5eedbc7a54/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f77742d6865616c74682f6c61726176656c2d656e756d2d7472616e73666f726d65722f6261646765732f636f7665726167652e706e673f623d6d617374657226733d62643838623330396133343561386164383437633539376538633732633139313632303765373133)](https://scrutinizer-ci.com/g/wt-health/laravel-enum-transformer/?branch=master)

Adds transformation support for [bensampo/laravel-enum](https://github.com/BenSampo/laravel-enum) based enums to the [spatie/laravel-typescript-transformer](https://github.com/spatie/laravel-typescript-transformer) package.

Installation &amp; Configuration
--------------------------------

[](#installation--configuration)

```
 composer require wthealth/laravel-enum-transformer
```

Add the following `Transformer` to the configuration `config/type-script-transformer`

```
'transformers' => [
    Webtools\LaravelEnumTransformer\LaravelEnumTransformer::class,
],

```

Usage
-----

[](#usage)

Now any enum created based on `BenSampo\Enum\Enum` can be transformed to typescript like below

```
final class UserType extends Enum
{
    const Administrator = 0;
    const Moderator = 1;
    const Subscriber = 2;
    const SuperAdministrator = 3;
}
```

```
export type UserType = {
    Administrator = 0,
    Moderator = 1,
    Subscriber = 2,
    SuperAdministrator = 3,
}
```

Or transform to enums:

This must be enabled in `config/type-script-transformer`

`'transform_to_native_enums' => true,`

```
export enum UserType {
    Administrator = 0,
    Moderator = 1,
    Subscriber = 2,
    SuperAdministrator = 3,
}
```

Read the [documentation](https://spatie.be/docs/typescript-transformer/v1/introduction) for further details.

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.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 ~259 days

Total

4

Last Release

1170d ago

PHP version history (2 changes)1.0.0PHP ^7.4|^8.0

1.0.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fe4edc8748b6ac4922ab8d16f64de61ad0b552027d8c1630646f6a0d6f09b9d?d=identicon)[badams](/maintainers/badams)

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

---

Top Contributors

[![badams](https://avatars.githubusercontent.com/u/340715?v=4)](https://github.com/badams "badams (13 commits)")[![Matt-Web](https://avatars.githubusercontent.com/u/572459?v=4)](https://github.com/Matt-Web "Matt-Web (2 commits)")[![pyrou](https://avatars.githubusercontent.com/u/235005?v=4)](https://github.com/pyrou "pyrou (1 commits)")[![securit](https://avatars.githubusercontent.com/u/168565?v=4)](https://github.com/securit "securit (1 commits)")

---

Tags

enumtypescripttypescript-transformerwebtoolslaravel-typescript-transformer

###  Code Quality

TestsPHPUnit

Code StyleECS

### Embed Badge

![Health badge](/badges/wthealth-laravel-enum-transformer/health.svg)

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

###  Alternatives

[myclabs/php-enum

PHP Enum implementation

2.7k227.9M637](/packages/myclabs-php-enum)[spatie/laravel-typescript-transformer

Transform your PHP structures to TypeScript types

3736.0M45](/packages/spatie-laravel-typescript-transformer)[dasprid/enum

PHP 7.1 enum implementation

382146.0M11](/packages/dasprid-enum)[spatie/enum

PHP Enums

84529.1M68](/packages/spatie-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49644.8M97](/packages/marc-mabe-php-enum)[spatie/typescript-transformer

This is my package typescript-transformer

3706.5M16](/packages/spatie-typescript-transformer)

PHPackages © 2026

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