PHP code example of olivermbs / enumshare

1. Go to this page and download the library: Download olivermbs/enumshare library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

olivermbs / enumshare example snippets




namespace App\Enums;

use Olivermbs\Enumshare\Attributes\Label;
use Olivermbs\Enumshare\Attributes\Meta;

enum Status: string
{
    #[Label('Active')]
    #[Meta(['color' => 'green'])]
    case Active = 'active';

    #[Label('Inactive')]
    #[Meta(['color' => 'red'])]
    case Inactive = 'inactive';
}

'mode' => 'full',  // or 'minimal'

// config/enumshare.php
return [
    'enums' => [
        App\Enums\Status::class,
    ],
    'path' => resource_path('js/Enums'),
    'mode' => 'full',  // 'full' or 'minimal'
    'auto_discovery' => true,
    'auto_paths' => ['app/Enums'],
];
bash
php artisan enums:export
bash
php artisan vendor:publish --tag="enumshare-config"
bash
php artisan enums:export              # Export enums
php artisan enums:export --force      # Rewrite all, even if unchanged
php artisan enums:export --list       # List enums that would be exported
php artisan enums:export --index      # Generate barrel index file
php artisan enums:export --types      # Export TypeScript helper types
php artisan enums:export --path=...   # Override export path
php artisan enums:export --locale=... # Override locale for labels
javascript
// vite.config.js
import { wayfinder } from '@laravel/vite-plugin-wayfinder';

export default defineConfig({
  plugins: [
    wayfinder({
      command: 'php artisan enums:export --force',
      patterns: ['app/Enums/**/*.php', 'lang/**/*.php', 'config/enumshare.php'],
    }),
  ],
});