xidanko/ts-enums-generator

Generates typescript enums from php enums.

v1.0.2 2025-01-08 21:34 UTC

This package is auto-updated.

Last update: 2025-06-08 22:28:27 UTC


README

ts-enums-generator is a Laravel package that generates TypeScript enums from PHP enums. It replicates the folder structure of the source directory using customizable naming conventions.

Installation

To install the package, use Composer:

composer require xidanko/ts-enums-generator

Configuration

You can publish the configuration file using the following command:

php artisan vendor:publish --tag=ts-enums-generator-config

Usage

To generate TypeScript enums from PHP enums, use the following command:

php artisan ts-enums:generate --source=[default: "app/Enums"] --destination=[default: "resources/ts/enums"]

Options

  • --source: The directory containing the PHP enums. This option has a default value that can be set in the configuration file.
  • --destination: The directory where the TypeScript enums will be generated. This option has a default value that can be set in the configuration file.

Customization

You can customize the naming conventions for the created folders and files using the configuration file. The package will replicate the folder structure of the source directory using the provided naming conventions.

Available naming conventions are: kebab, snake, studly, and camel.

License

This package is open-sourced software licensed under the MIT license.