Download the PHP package gigerit/laravel-morphmap-js-generator without Composer
On this page you can find all versions of the php package gigerit/laravel-morphmap-js-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gigerit/laravel-morphmap-js-generator
More information about gigerit/laravel-morphmap-js-generator
Files in gigerit/laravel-morphmap-js-generator
Package laravel-morphmap-js-generator
Short Description Generate frontend JavaScript/TypeScript constants from Laravel morph map configuration
License MIT
Informations about the package laravel-morphmap-js-generator
Laravel Morph Map JS Generator
Generate frontend JavaScript/TypeScript constants from your Laravel application's morph map configuration. Keep your frontend morph types in sync with your Laravel models automatically.
Installation
You can install the package via composer:
The package will automatically register itself with Laravel.
Usage
After installation, you can generate the JavaScript/TypeScript constants using the artisan command:
Example
If your Laravel application has this morph map configuration:
The command will generate a JavaScript/TypeScript file with these constants:
Using in Your Frontend
Features
- 🔄 Automatically syncs with Laravel's morph map configuration
- 📝 Generates JavaScript or TypeScript files
- 🎯 Type-safe with TypeScript support
- 🔍 Includes helper function for model name lookup
- 🎨 Converts numeric keys to readable constant names
- 📦 Zero configuration required
- 💻 Command output shows current mappings
Command Options
Option | Description | Default |
---|---|---|
--ts |
Generate TypeScript instead of JavaScript | false |
--path |
Custom output path for generated file | resources/js |
Best Practices
- Version Control: Add the generated file to your version control system to track changes.
-
Build Process: Include the generation command in your build process to ensure sync:
- Type Safety: Use TypeScript for better type checking and IDE support.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.