Download the PHP package fanmade/laravel-bitwise-trait without Composer

On this page you can find all versions of the php package fanmade/laravel-bitwise-trait. 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-bitwise-trait

Laravel Bitwise Trait

A simple trait to use bitwise operators on any class Inspired by http://php.net/manual/de/language.operators.bitwise.php#108679

Updated after reading this blog post: https://aaronfrancis.com/2021/bitmasking-in-laravel-and-mysql

I just used it in Laravel so far, but you should be able to use it anywhere else with minor modifications.

PHP Version

Version v2. requires PHP 7.4+. If you're stuck to an older version, please use v1.

Installation

You can install the package via composer:

That's all, no provider registration needed :)

Usage

This example is for a default Laravel (5.4) Model within the "App" namespace.

You need an (ideally unsigned) integer field in your database which will store the properties. The length does depend on the number of values you would like to store. You only need one bit per value, so it's 8 values for each byte, if the column is unsigned.

Examples (based on laravel migrations):

You get the idea. Most times you probably only need an unsigned tinyInteger :)

There are only a few use-cases for more than one database field, but you can add as many fields as you like.

Include the Trait in your model like this:

The best way to define your properties is via constants directly in the model. You're of course free to use config variables or whatever you prefer.

This alternative syntax may be easier to read:

Or directly in binary notation:

To set a property, just call the function like this:

To get a property, just call the function like this:

The first parameter ('status' in the example) is always the column you set in the database. Maybe you want to define that in a constant or variable.

To make your life easier, I recommend to use custom getters and setters.

Scopes

If you want to use the new field in scopes, you can do that like this:


All versions of laravel-bitwise-trait with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 fanmade/laravel-bitwise-trait contains the following files

Loading the files please wait ....