PHPackages                             marcionunes/penum-type - 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. marcionunes/penum-type

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

marcionunes/penum-type
======================

For laravel. Convert your php enum to typescript .d.ts

v1.0.2(9mo ago)079[1 PRs](https://github.com/marciano0695/penum-type/pulls)MITPHPPHP ^8.3.0

Since Aug 10Pushed 6mo agoCompare

[ Source](https://github.com/marciano0695/penum-type)[ Packagist](https://packagist.org/packages/marcionunes/penum-type)[ Docs](https://github.com/marciano0695/penum-type)[ RSS](/packages/marcionunes-penum-type/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Enum to TypeScript Types definitions
============================================

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

This package automatically generates **TypeScript type definitions** (`.d.ts` files) from your Laravel enums, so you can keep backend and frontend in perfect sync without manually duplicating definitions. Default method of enum to generate is **frontend** it can be change on the configuration file.

---

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

[](#installation)

Require the package via Composer:

```
composer require marcionunes/penum-type
```

Change config file to your needs

---

Generating the TypeScript file
------------------------------

[](#generating-the-typescript-file)

```
php artisan penum-type:generate
```

This will generate a `enums.d.ts` file at the configured output path.

---

Example
-------

[](#example)

### PHP Enums

[](#php-enums)

**MessageTypeEnum**

```
