Download the PHP package intrfce/laravel-frontend-enums without Composer
On this page you can find all versions of the php package intrfce/laravel-frontend-enums. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download intrfce/laravel-frontend-enums
More information about intrfce/laravel-frontend-enums
Files in intrfce/laravel-frontend-enums
Package laravel-frontend-enums
Short Description Stop using 'magic' strings/numbers in your frontend Javascript and use your actual application enums instead.
License MIT
Homepage https://github.com/intrfce/laravel-frontend-enums
Informations about the package laravel-frontend-enums
Laravel Frontend Enums
Publish your PHP enums to the front-end of your application, so you can refer to them in your JavaScript code.
This means less reliance on "magic strings".
`
Installation
You can install the package via composer:
Usage
Just add the attribute!
Add the #[PublishEnum] attribute to any enum you want published to the frontend - it's that easy.
Then run the publish command:
Your enums will be waiting at resources/js/Enums with the extension .enum.js:
Configuration
Publish the config file to customise the output path and discovery directories:
The discover_in array supports glob patterns, which is useful for modular or monorepo layouts:
Typescript Support
Enable TypeScript output globally via the config file:
Or override per-enum using the attribute:
TypeScript enums are output as .ts files:
Automatically generate javascript files on change.
You can use the vite-plugin-watch package from lepikhinb to automatically generate your javascript files when you make changes to your PHP enums:
Then add the plugin to your vite.config.js:
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Dan Matthews
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-frontend-enums with dependencies
laravel/framework Version ^11.0 || ^12.0 || ^13.0
laravel/prompts Version v0.*
spatie/php-structure-discoverer Version ^2.0