Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Supercharged Enums Laravel Package

bensondevs/supercharged-enums

Supercharged Enums adds helpful, expressive methods to PHP 8.1+ enums so you can do more with less code in your Laravel apps. It keeps enum logic clean and readable, with a simple API for common tasks like labels, comparisons, and validation.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with Composer; Laravel package discovery registers SuperchargedEnumsServiceProvider automatically, so no manual provider registration is needed.

If you want generated enums to include EnumExtension out of the box, publish the package stubs before creating your first enum:

php artisan vendor:publish --tag=supercharged-enums-stubs

Then generate a backed enum:

php artisan make:enum Status --string

Open the generated file first and confirm it imports and uses EnumExtension. That is the quickest way to verify the package is wired correctly.

If you use Laravel Boost or AI-assisted development, look at resources/boost/ next. The package ships a supercharged-enums-development skill and guidelines. Run:

php artisan boost:install
# or, for an existing Boost setup:
php artisan boost:update --discover

A good first use case is a Status enum used for model state, form options, and validation rules.

Implementation Patterns

Generate enums through Artisan. Prefer php artisan make:enum Status --string or --int over hand-writing files so the package stub and EnumExtension wiring stay consistent.

Use backed enums at boundaries. String-backed enums are convenient for database values, API payloads, and logs. Int-backed enums are better for compact storage. Pick one and avoid changing the backing type after data exists.

Centralize enum behavior with EnumExtension. Keep labels, colors, options, and small presentation helpers on the enum itself, then reuse them in validation, forms, and API resources:

Rule::enum(Status::class);
Status::options();
Status::from($value)->label();

Customize the stub once, then regenerate. Publish the stubs, edit enum.backed.stub to match team conventions, and commit the published stub if you want consistent output across the team. Regenerate rather than hand-editing generated files.

Use the Boost skill as an agent contract. After boost:update --discover, AI agents can read the package guidelines and follow the expected enum structure. Pair this with make:enum so agents generate enums through the same path as human developers.

Keep enum logic small. EnumExtension is best for presentation and lookup helpers. Avoid putting heavy domain workflows or database access inside enums; move those to services or actions.

Gotchas and Tips

  • Publish stubs before generating enums. The customized enum.backed.stub is opt-in. If you run make:enum first, you may get enums without EnumExtension and need to regenerate or edit them.
  • Package discovery failures look like missing commands. If make:enum is unavailable, run composer dump-autoload and php artisan package:discover, then clear caches with php artisan optimize:clear.
  • Boost resources are not retroactively discovered. Existing Boost installations need php artisan boost:update --discover; boost:install only covers the initial setup path.
  • Do not edit vendor stubs. Publish them with --tag=supercharged-enums-stubs and customize the copy in your application.
  • Watch for command or namespace collisions. If your app already defines a make:enum command or custom enum base class, adjust the published stub and confirm the package command is the one being resolved.
  • Check the generated import. If EnumExtension is missing after generation, inspect the published stub and confirm the enum imports the correct trait namespace.
  • Add app-level tests for critical enums. The package includes validation tests for its Boost resource structure, but your application should still assert that important enums expose the expected labels, options, and validation behavior.
  • Upgrading to v0.2.0 is additive. The release adds Boost support and publishable stubs; no breaking changes are called out. After upgrading, republish stubs if you rely on them and run boost:update --discover if you use Boost.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings