- How do I install isap-ou/laravel-enum-helpers?
- Install the package with Composer by running composer require isap-ou/laravel-enum-helpers in your Laravel project. Laravel package auto-discovery should register the service provider, so no manual registration is normally required. If the package ships configuration or translation files, follow the repository README to publish them. After installation, confirm the exact setup steps in the package documentation.
- What PHP and Laravel versions does this package require?
- Because the package works with native PHP enums, your application must run PHP 8.1 or newer. The exact Laravel framework constraint is defined in the package composer.json and on Packagist. Check those constraints before installing to make sure they match your application version.
- How do I add translatable labels to PHP enum cases?
- The package provides helpers for converting enum cases into human-readable, translatable labels for Blade views, API resources, and validation messages. You define the label text through the package's supported configuration or language files, then use the label helper on the enum case or enum class. Refer to the README for the exact helper names and translation file structure, since those details are package-specific.
- Can I generate an options array for a form select from an enum?
- Yes, the package includes helpers that return enum cases as an option array suitable for Blade select inputs and form components. This avoids writing repetitive foreach loops that map enum values to labels. You can pass the resulting array directly to your view or form builder.
- How does MySQL enum column sync work with this package?
- The package can generate value collections from your PHP enums for use in migrations and includes support for syncing those values with a MySQL enum column. This helps keep the database column definition aligned with the enum cases defined in your code. Review the generated migration or sync behavior in the README before applying it to a production database.
- Can I export PHP enums to JavaScript with this package?
- Yes, one of the package's features is exporting enum cases to JavaScript so frontend code can use the same values as the backend. This is useful for Vue, React, or plain JavaScript components that need enum values for dropdowns or validation. Check the README for the export command or helper and how to consume the generated file in your frontend build.
- Does the package help with validating enum values in Laravel?
- The package overview mentions validation support, so it provides helpers or rules that make it easier to confirm an input matches a valid enum case. You can use this in form requests, controllers, or Livewire components. Confirm the exact rule class or helper name in the package documentation before wiring it into your validation logic.
- How does laravel-enum-helpers keep Blade views consistent with enum values?
- The package gives you a single source of truth for enum labels and values, so Blade templates can render the same human-readable labels used elsewhere in the application. Instead of hardcoding strings in views, you call the package's label or option helpers. This reduces mismatches when enum cases are renamed or added.
- Is this package a replacement for spatie/laravel-enum or benSampo/laravel-enum?
- This is a lightweight helper package focused on labels, option arrays, migration values, MySQL enum sync, and JavaScript export. It is not necessarily a full replacement for larger enum packages that provide model casting, attributes, or extensive rule sets. Evaluate which features your application actually uses before switching from another enum package.
- Is isap-ou/laravel-enum-helpers suitable for production use?
- It is a small Composer utility package intended to reduce repetitive enum code in Laravel applications. Before using it in production, check the repository's release history, open issues, test coverage, and Laravel version constraint. Review any MySQL enum sync or migration behavior carefully, since schema changes carry risk.