Integration
This package is framework-agnostic, so integration is usually just normal PHP usage.
Typical integration points
- DTO validation and serialization
- form/select option generation
- API filtering with
ComparisonOperator - logging decisions with
LogLevel - runtime configuration with
Environment - custom sort implementations using
SortDirectionandComparisonResult - date/time calculations with
Month,Quarter, andIntervalUnit
Typical application patterns
Common integration patterns include:
- building form option lists from
options()orEnumHelper::options() - validating case names coming from user input with
fromName()orhasName() - converting backed values from storage or APIs into cases
- sharing stable enums such as
EnvironmentorLogLevelacross multiple packages
Container usage
No service provider is required. Import the enum or helper directly where needed.
Framework usage
In frameworks, this usually means:
- enums live in your domain or shared library namespace
- traits are added to enums you own
EnumHelperis used in UI adapters, serializers, controllers, and validators
There is no special registration step.
Troubleshooting
- If a helper expects a backed enum, prefer
EnumHelpermethods that are documented forBackedEnumrather than plainUnitEnum. - If you need business-specific labels or transitions, create your own enum instead of forcing packaged catalogs to fit.
- When reorganizing enums across namespaces in your own project, run
composer dump-autoloadbefore debugging missing classes. - If names and values are getting mixed up in external input, document clearly whether your boundary accepts case names or backed values.