Download the PHP package saas-laravel/laravel-enums-to-json without Composer
On this page you can find all versions of the php package saas-laravel/laravel-enums-to-json. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saas-laravel/laravel-enums-to-json
More information about saas-laravel/laravel-enums-to-json
Files in saas-laravel/laravel-enums-to-json
Package laravel-enums-to-json
Short Description This package generates a json file off of values from enum
License MIT
Homepage https://github.com/saas-laravel/laravel-enums-to-json
Informations about the package laravel-enums-to-json
Laravel Attributed Enums to json
The idea for this package is to streamline the process of sharing enums values between backend and frontend.
If you use Laravel as a backend for a frontend framework like Nuxt or Next, and they both live in the same project, you can utilize it to generate a json file from your enums.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
In order to use the package, you need to add SaasLaravel\LaravelEnumsToJson\Attributes\EnumToJson
attribute to your enum
Example usage:
Then you'd run a command to generate the json files.
Customizing the name
By default, it generates a file named as a normalized version of the enum name - that'd be cast_type.json
if the example above didn't contain the jsonFileName
method. However, because it is present, it'd generate cast.json
instead.
Testing
Credits
- przemyslaw-przylucki
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-enums-to-json with dependencies
illuminate/contracts Version ^11.0
spatie/laravel-package-tools Version ^1.14.0
spatie/php-structure-discoverer Version ^2.0