- Is ex3v/myclabs-enum-param-converter a Laravel package or a Symfony bundle?
- Despite often being listed alongside Laravel packages, it is a Symfony bundle. It registers MyCLabsEnumParamConverterBundle in AppKernel.php and hooks into SensioFrameworkExtraBundle's @ParamConverter pipeline, which is a Symfony-only extension point. There is no equivalent registration seam in Laravel's router or HTTP kernel, so the package cannot be installed meaningfully in a Laravel app. For Laravel, the same goal is solved by native backed enums plus implicit route binding.
- Can I install this package in a Laravel application?
- No. The bundle depends on Symfony's bundle registration lifecycle and the annotation reader used for @ParamConverter, neither of which exists in Laravel. Laravel's nearest analogues are implicit route model binding and FormRequest validation, and there is no place to register a ParamConverterInterface implementation. The practical recommendation is to read the source as a reference rather than depend on it.
- How do I install and register the MyCLabs enum param converter bundle?
- Run composer require ex3v/myclabs-enum-param-converter, then add new \Ex3v\MyCLabsEnumParamConverterBundle\MyCLabsEnumParamConverterBundle() to registerBundles() in app/AppKernel.php. In your controller, type-hint the enum argument and annotate it with @ParamConverter("barType"). The converter is selected automatically from the type hint, or you can force it with converter="converter_enum".
- How do I automatically convert a route parameter to an enum in Laravel?
- On PHP 8.1+ define the enum as a backed enum, for example enum BarType: string, and type-hint it on the route closure or controller action. Laravel 9+ resolves backed enums from route segments automatically when the parameter name and type hint match. For more control use Route::bind(), or validate the value in a FormRequest with Rule::enum(BarType::class).
- Does this converter support native PHP 8.1 backed enums?
- No. It exists specifically to cast a route parameter string into an instance of a MyCLabs\Enum class. Native backed enums are handled by the framework itself, and the converter's whole purpose disappears once you have PHP 8.1 available. If your project already targets 8.1 or newer, you do not need this dependency or MyCLabs\Enum at all.
- Is MyCLabs\Enum deprecated, and should I still use it?
- Yes, MyCLabs\Enum has been superseded by native PHP 8.1 backed enums and the upstream project is in a maintenance posture. Adding this converter also imports that deprecated dependency transitively for convenience only. On any project running PHP 8.1+, the built-in enum feature removes the need for both packages.
- Which Symfony versions does this bundle support?
- The README registers the bundle in app/AppKernel.php, which points at Symfony 2.8/3.x era applications. Symfony Flex projects use config/bundles.php instead, and Symfony 5+ no longer ships the AppKernel pattern at all. It also assumes SensioFrameworkExtraBundle's annotation layer is installed and enabled, which many modern Symfony apps have removed.
- Does the bundle work with PHP 8 attributes instead of @ParamConverter annotations?
- The documented usage is annotation-based and the converter is wired through the annotations reader. The README shows no attribute syntax, and the whole @ParamConverter mechanism is on a deprecation path as Symfony moves to attributes. If your app has already migrated to attributes, the annotation-driven usage shown in the README will not fire as written.
- Is this package safe to use in production, or is it abandoned?
- The maintenance signals are weak: roughly 8 stars, no dependents, a single maintainer, and a Travis CI badge that no longer reflects active CI for open source. There is no visible test suite, and maturity is README-level. The mitigating factor is that the surface area is tiny and auditable, so supply-chain risk is low, but the code is better treated as a reference than a dependency.
- How do I migrate from MyCLabs\Enum classes to native PHP enums in Laravel?
- Rewrite each MyCLabs\Enum class as a backed enum with a string or int type and keep the same case names, then replace constructor-style or static call usages with enum cases. Delete the converter bundle and MyCLabs\Enum from Composer once nothing references them. Type-hint the enum in controllers and routes and rely on implicit binding; for input validation add Rule::enum(YourEnum::class) in a FormRequest. Run your test suite to confirm every previously converted route parameter now resolves to the correct case.