Download the PHP package bensondevs/supercharged-enums without Composer

On this page you can find all versions of the php package bensondevs/supercharged-enums. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package supercharged-enums

⚡ Supercharged Enums

Backed enum helpers (find, options, comparisons, labels) via the EnumExtension trait—no framework dependencies. The package also ships optional ready-made enums for everyday domains (HTTP, calendar and time, measurement units, finance, logging, deployment environments, and more) under BensonDevs\SuperchargedEnums\Common\, each wired with the same helpers. See Bundled Common enums.

Requirements: PHP 8.2 or later. The EnumExtension trait targets backed enums (string or int). Pure unit enums without a backing type are not supported by lookup normalization.

Table of contents

Installation

Laravel Boost

This package ships Laravel Boost AI resources for coding agents:

Boost discovers these automatically from resources/boost/ in the installed package. No ServiceProvider or extra configuration is required in this library.

In a Laravel project that uses Boost:

Boost integration is opt-in on the consumer side. The package remains framework-agnostic.

Laravel Artisan stubs

For Laravel projects, you can publish a customized enum.backed.stub so php artisan make:enum generates backed enums with EnumExtension already applied.

Enable (one-time, manual):

Generate enums as usual:

Example output:

Notes:

Quick start

Add the trait to your own enum, or use a bundled one from Common\—same helpers either way.

Your enum

Lookup — request / DB strings → cases (null when unknown)

Labels and forms

Comparisons — declaration order, not backing-value sort

Bundled time unitsDurationUnit with conversions and the same helpers

Bundled measurement unitsCommon\Measure

More domains (HTTP status codes, money rounding, data sizes) are listed under Bundled Common enums.

Features

Modular composition.

Core helpers

default() follows declaration order, not the smallest or largest backing value. For example, HttpStatusCode defaults to Continue (100) because it is declared first, even though other codes have smaller numeric semantics in different contexts.

There is no separate config flag: declare the case you want as the default first, or override default() on your enum to return any case you prefer. findOrDefault() and any code that falls back to default() will use whichever you define.

If you use a partial trait stack without EnumExtension, define default() yourself (for example return self::cases()[0];) so findOrDefault() keeps working.

Lookup

find() accepts:

When $strict is false and tryFrom() does not match, cases may define alternate keys via an instance method:

Case listing

Naming

getName() normalizes case names for display: underscores and hyphens become spaces, PascalCase is split, and the result is title-cased (NoShow"No show", FirstOption"First option").

Select maps

Build value => label maps for HTML <select> elements, JSON APIs, and similar UIs.

Label resolution (options()), first match wins:

  1. label() instance method
  2. getLabel()
  3. getName()
  4. Raw PHP case name

Description resolution (asSelectDescriptions()):

  1. getDescription()
  2. getLabel()
  3. Raw PHP case name

Filtering which cases appear in maps

Define either an allow-list or a deny-list as a static method returning enum cases and/or backing scalars:

Comparisons and ordering

Operands accept enum instances, backing scalars, or null. Scalars and aliases resolve through find() (non-strict), same as lookup.

Declaration order, not backing values

Ordering methods (compareTo, isBefore, isAfter, next, previous, min, max, and related helpers) use the index in cases(), not numeric or lexical order of backing values. A case declared first with backing value 2 is still “before” a case declared second with backing value 1.

Notes:

Equality

Order — declaration order, not backing-value sort

Range — reversed bounds are swapped automatically

Position

Navigationnull at the end unless $wrap is true

Aggregates — skip unresolvable operands; null if none resolve

Modular composition

Individual concerns live under src/Concerns/ and can be used without the full trait:

Caveat: findOrDefault() calls default(), which is defined on EnumExtension, not on EnumLookup alone. With a partial stack, use find($key) ?? self::cases()[0] or add your own default() helper.

🔋 Bundled Common enums

Optional backed enums under BensonDevs\SuperchargedEnums\Common\. Each uses Core helpers to override.

Per-enum case lists and domain-specific methods are documented under docs/common/.

Domain Documentation Enums
Angle Angle AngleUnit
Application Application DeploymentEnvironment
Calendar Calendar DateDisplayFormat, DayOfWeek, Month, Quarter
Cryptography Cryptography HashAlgorithm
Data size DataSize BinaryDataSizeUnit, DecimalDataSizeUnit
Database Database DatabaseEngine
Device Device DeviceType
Finance Finance CardBrand, MoneyRoundingMode
Geography Geography CompassDirection, Hemisphere
HTTP Http HttpMethod, HttpStatusCode
Identity Identity IdentityDocumentType
Logging Logging LogLevel
Measure Measure AreaUnit, EnergyUnit, FrequencyUnit, LengthUnit, MassUnit, PowerUnit, PressureUnit, SpeedUnit, TemperatureUnit, VolumeUnit
MIME Mime MediaTypeClass
Platform Platform CpuArchitecture, OperatingSystemFamily
Text Text TextCasing, TextTransform
Time Time DurationUnit, Season, TimePrecision

Usage examples

Behavior is covered by the Pest test suite.

Development

Support

If this package saves you time, consider supporting its maintenance:

Thank you for helping keep Supercharged Enums maintained.

License

MIT


All versions of supercharged-enums with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bensondevs/supercharged-enums contains the following files

Loading the files please wait ...