PHPackages                             saas-laravel/laravel-enums-to-json - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. saas-laravel/laravel-enums-to-json

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

saas-laravel/laravel-enums-to-json
==================================

This package generates a json file off of values from enum

4.0.0(5mo ago)648.4k↓71.6%1[1 PRs](https://github.com/saas-laravel/laravel-enums-to-json/pulls)MITPHPPHP ^8.3CI failing

Since Sep 4Pushed 5mo agoCompare

[ Source](https://github.com/saas-laravel/laravel-enums-to-json)[ Packagist](https://packagist.org/packages/saas-laravel/laravel-enums-to-json)[ Docs](https://github.com/saas-laravel/laravel-enums-to-json)[ RSS](/packages/saas-laravel-laravel-enums-to-json/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (9)Versions (7)Used By (0)

Laravel Attributed 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
------------

[](#installation)

You can install the package via composer:

```
composer require saas-laravel/laravel-enums-to-json
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-enums-to-json"
```

This is the contents of the published config file:

```
return [
    // The disk, defined in filesystem.php, where json files will be stored
    'disk' => 'public',

    // The folder on that disk where json will be generated
    'path' => '/shared',

    'enum_locations' => [
        app_path(),
    ],
];
```

Usage
-----

[](#usage)

In order to use the package, you need to add `SaasLaravel\LaravelEnumsToJson\Attributes\EnumToJson` attribute to your enum

Example usage:

```
