- Can I use this bundle directly in Laravel without Symfony?
- No, this bundle is designed for Symfony and requires its Kernel, DependencyInjection, and Twig components. You’d need to manually replicate its functionality in Laravel (e.g., register `AbstractEnumMapper` classes as services and create custom Twig/Blade helpers).
- How do I convert database enum values to human-readable labels in Laravel?
- For Laravel, consider native PHP 8.1 enums or packages like `spatie/laravel-enum` for direct conversion. If using Doctrine, its built-in enum support may suffice. This bundle’s Twig filters won’t work natively without Symfony.
- What’s the easiest way to validate enum values in Laravel?
- Laravel’s built-in `Validator` facade or `FormRequest` validation rules (e.g., `in:male,female`) are simpler. This bundle’s validator integration is Symfony-specific and requires extra setup for Laravel.
- Does this bundle work with Laravel’s Blade templating engine?
- No, the bundle provides Twig filters/functions. For Blade, you’d need to create custom directives or use a package like `spatie/laravel-twig` to bridge Twig functionality, adding complexity.
- What Laravel versions support this bundle’s underlying EnumMapper?
- The `enum-mapper` component is PHP-agnostic and works in Laravel, but the *bundle* itself requires Symfony. For Laravel, use `enum-mapper` directly (PHP 7.4+) or leverage PHP 8.1’s native enums.
- Are there Laravel alternatives to this bundle for enum handling?
- Yes: `spatie/laravel-enum` (Blade/Twig support), `myclabs/php-enum` (PHP 5.6+), or native PHP 8.1 enums with Doctrine. These avoid Symfony dependencies entirely.
- How do I integrate this bundle’s Twig filters in Laravel with Twig?
- First install `spatie/laravel-twig`, then manually create a custom Twig extension in Laravel to replicate the bundle’s `enum_to_human`, `enum_to_db`, and `enum_map` logic using `AbstractEnumMapper`.
- Will this bundle break if I upgrade Laravel or PHP?
- The bundle itself is Symfony-dependent, but the core `enum-mapper` component is stable. Upgrading Laravel/PHP may require adapting the bundle’s Symfony-specific code (e.g., `ContainerInterface` changes).
- Can I use this bundle for API responses (e.g., JSON enum labels)?
- No, this bundle is template-focused (Twig). For APIs, use Laravel’s `Response` macros, `spatie/laravel-enum`, or PHP 8.1 enums with JSON serialization.
- How do I test this bundle in a Laravel project?
- Test the underlying `enum-mapper` component directly in Laravel by mocking its `AbstractEnumMapper` classes in PHPUnit. Skip the bundle’s Symfony-specific tests unless you’re building a hybrid Symfony/Laravel setup.