- How do I install cerbero/enum in a Laravel application?
- Install it with Composer using composer require cerbero/enum. It is a zero-runtime-dependency Laravel utility, so adding it to an existing application should be straightforward. After installation, confirm Laravel package auto-discovery picks up any service provider, then apply the package traits or interfaces to a few selected enums instead of refactoring every enum at once.
- Which Laravel and PHP versions does cerbero/enum support?
- Native enums require PHP 8.1 or higher, so treat that as the baseline. Check the package composer.json constraints and the repository CI matrix for the exact Laravel versions tested before adopting it. If your estate spans multiple Laravel versions, gate adoption by version or isolate usage behind project-owned enum helpers.
- Can I use cerbero/enum with my existing backed enums?
- Yes. The package is designed to enhance existing native PHP enums rather than replace them, so you can start incrementally. Apply its traits or interfaces to one or two enums, such as order status or user role, and compare the result against a handwritten helper baseline. Verify that your own project-specific enum traits remain composable before expanding.
- Does cerbero/enum integrate with Laravel validation and form requests?
- The package adds validation rules so enum values can be validated in form requests and controllers. Confirm the behavior against your Laravel version with a small integration test. If a rule does not cover a specific case, wrap it in your own rule rather than spreading custom glue across the codebase.
- How does Eloquent casting work with cerbero/enum?
- The package provides Eloquent casting so enum attributes hydrate into rich enum objects. Test database round-trips and API resource output because casting changes what your application receives from the model. Also check behavior with queued jobs and serialization before using it on critical models.
- Does cerbero/enum add runtime reflection overhead on hot paths?
- The package may use attributes or reflection to resolve labels and metadata, which can add cost on frequently hit paths. Benchmark the paths that matter, such as serializing large collections, and cache metadata where possible. If overhead is measurable, keep the package in UI and validation layers rather than tight loops.
- Is cerbero/enum safe to use in production?
- Risk is moderate-low because it has zero runtime dependencies and an MIT license, but the low dependent count is an adoption signal. Pilot it on one non-critical enum, add unit, integration, serialization, and validation tests, and document approved usage patterns. Avoid making it the only source of truth for business-critical enum metadata without a documented fallback.
- What are the alternatives to cerbero/enum for Laravel enums?
- Alternatives include native PHP 8.1 enums plus a small internal trait or helper, or other Laravel enum packages. Compare clarity, static analysis support, and IDE experience against a handwritten baseline before committing. Because the package API is small, wrapping it behind an internal helper keeps an exit path open.
- How do I get localized labels and Blade options from enums?
- The package adds localization and Blade helpers so enums can produce translated labels and UI option lists. That reduces boilerplate in admin screens and select inputs. Test translations and fallbacks across your supported locales, and keep presentation concerns out of pure domain models.
- How is cerbero/enum maintained and what is its backward-compatibility policy?
- Review the repository release cadence, changelog, and maintainer responsiveness before standardizing on it. The low dependent count warrants a bounded pilot rather than a broad rollout. Reassess after one Laravel upgrade cycle or if maintainer activity stalls.