Download the PHP package toniel/laravel-enum-to-typescript without Composer
On this page you can find all versions of the php package toniel/laravel-enum-to-typescript. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download toniel/laravel-enum-to-typescript
More information about toniel/laravel-enum-to-typescript
Files in toniel/laravel-enum-to-typescript
Package laravel-enum-to-typescript
Short Description A Laravel package to convert PHP enums to TypeScript.
License MIT
Informations about the package laravel-enum-to-typescript
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
You can install the package via composer:
Configuration
To publish the configuration file, run the following command:
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.
Usage
To convert your PHP enums to TypeScript, run the following artisan command:
The command will scan the source_dir for PHP enums and generate the corresponding TypeScript enums in the dest_dir.
Options
You can override the default configuration by passing options to the command:
-
--source: Specify the source directory for PHP enums. -
--dest: Specify the destination directory for TypeScript enums. -
--filename-case: Specify the case for the generated filenames (PascalCaseorkebab-case). --strategy: Specify the output strategy (single_fileormultiple_files).
Example
Given a PHP enum:
Running the command will generate the following TypeScript enum:
Multiple Files Strategy (default)
A new file resources/ts/Enums/UserRole.ts will be created:
Single File Strategy
A single file resources/ts/Enums/enums.ts (or your configured single_file_name) will be created containing all enums:
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-enum-to-typescript with dependencies
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0
illuminate/console Version ^10.0 || ^11.0 || ^12.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0
nikic/php-parser Version ^4.17 || ^5.0