InvoiceStatus::SENT requires isPaid=false).spatie/array-to-object).register()/boot() methods.ClassMetaManager as a singleton for global access.{{ $status->meta('description') }}).JsonResource::withMeta()).doctrine/annotations).symfony/annotations).app() or Redis during boot.data array format limits extensibility (e.g., nested metadata).Meta annotation or use a wrapper class.doctrine/annotations?Rule::in(InvoiceStatus::class))?const DRAFT = ['code' => 'draft', 'label' => 'Draft'] to annotations.ClassMetaManager in tests.| Component | Integration Strategy |
|---|---|
| Laravel Core | Register ClassMetaManager in AppServiceProvider as a singleton. |
| Annotations | Use doctrine/annotations (if not bundled) for parsing. |
| Blade | Create a @meta() directive or helper: {{ meta('Acme\Enum\InvoiceStatus', 'name') }}. |
| API (Lumen/Fortify) | Extend JsonResource to include metadata: public function toArray($request) { ... 'meta' => $this->meta(), }. |
| Validation | Create a custom rule: Rule::meta('Acme\Enum\InvoiceStatus', 'code', 'SENT'). |
| Cache | Cache metadata in app() or Redis during boot (e.g., Cache::remember()). |
| Testing | Mock ClassMetaManager in PHPUnit or use data providers for enum tests. |
UserRole, OrderStatus).ClassMetaManager in Laravel’s service container.booted() event).['code' => 'draft']) to annotations.@deprecated annotations.return_type_declaration, strict_types=1, and scalar_type_hints in wrappers.symfony/annotations conflicts.composer.json).doctrine/annotations.ClassMetaManager in AppServiceProvider.@Meta to one enum/class (e.g., UserStatus).ClassMetaManager.phpdoc).doctrine/annotations).var_dump($manager->getClassMeta('ClassName')).php artisan cache:clear) if metadata updates don’t reflect.Acme\Enum\Status vs. acme/enum/status).php artisan meta:dump to log all metadata for debugging.Log::debug('Meta accessed:', ['class' => $class, 'key' => $key])).app() or Redis.spl_autoload_register to parse on-demand (risky; test thoroughly).| Scenario | Impact | Mitigation |
|---|---|---|
| Annotation Parser Fails | Metadata unavailable | Fallback to hardcoded defaults or cache. |
| Caching Issues | Stale metadata | Use cache tags or versioned keys. |
| PHP Version Incompatibility | Runtime |
How can I help you explore Laravel packages today?