Download the PHP package matthewpageuk/laravel-bitty-enums without Composer

On this page you can find all versions of the php package matthewpageuk/laravel-bitty-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 laravel-bitty-enums

Laravel Bitwise Enums

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads GitHub Issues

This package helps you use bitwise enums in your Laravel application if you choose to, think before you do. It provides an Enum Container, a trait for your model query scopes and a model attribute cast.

You can think of this as a hasMany relationship but using a single integer column to store the data.

bitty1

Installation

You can install the package into your Laravel project via composer:

Usage

Create an Enum

You can create a new enum using the bitty-enum:make Artisan command. This command will create a new enum class in the app/Enums directory with the cases you supply. It will ensure the values and names are suitable for use with the package.

To use your own enums with this package they must :

Invalid enums will throw an BittyEnumException when used with the container.

There is a current limit of 16 cases (bits) per enum. This can be overiding in your config files.

Example of a Colour enum:

Using the Bitty Enum Container

The container is used to store the selected enum values. It is a wrapper around the integer value and provides methods to manage and check the values. It also performs validation on the values you set to prevent accidental misuse.

Creating a container

You can create a new container using the Contract binding in the Laravel app.

This will create a container suitable for the Colour enum.

You can also use the MatthewPageUK\BittyEnums\Support\Container directly.

Example usage

Container public methods

Validation

The container also perfoms validation on the values you set, throwing a BittyEnumException if you try to set an invalid value or have a malformed enum.

Model Attribute Cast

You can cast the integer column on your models to a BittyEnumContainer using the MatthewPageUK\BittyEnums\Casts\BittyEnumCast cast.

You must pass the enum class you intend to use as the second parameter.

Your database column should be a BIGINT.

@todo see also bit limit on enum, how many can we have?

Example Laravel Model

You can now use the container methods to update and retrieve the enum values direct from your model attribute.

Example Usage

Scoped Queries

To access the scoped queries in your model you need to use the MatthewPageUK\BittyEnums\Traits\WithBittyEnumQueryScope trait.

You should also ensure your model has the BittyEnumCast set on the column you want to query.

Example Model

Example Queries

Methods accepting multiple choices can be an array of BittyEnum or a BittyEnumContainer.

A BittyEnumException will be thrown if you pass the incorrect type or invalid enum to the query scope.

Config settings

You can set the maximum number of bits for the container in the config file.

Package Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-bitty-enums with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0
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 matthewpageuk/laravel-bitty-enums contains the following files

Loading the files please wait ....