PHPackages                             jrmadsen67/mahana-bitmask - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jrmadsen67/mahana-bitmask

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jrmadsen67/mahana-bitmask
=========================

Bit masking to manage settings

v1.0.0(9y ago)1226MITPHPPHP &gt;=5.4

Since Sep 27Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jrmadsen67/mahana-bitmask)[ Packagist](https://packagist.org/packages/jrmadsen67/mahana-bitmask)[ Docs](https://github.com/jrmadsen67/mahana-bitmask)[ RSS](/packages/jrmadsen67-mahana-bitmask/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

MahanaBitfield
==============

[](#mahanabitfield)

Bit masking to manage settings. Rather than having a few dozen flags on every table, bit masking can be used to reduce them to a single integer value.

Installation
------------

[](#installation)

```
composer require jrmadsen67/mahana-bitmask

```

Usage
-----

[](#usage)

Typically we would use this in conjunction with an MVC model class, so I will use that scenario as an example.

MahanaBitfield is an abstract class, so you will create a simple inherited class for each setting field you wish to have.

This means that if you have a Users table and want to store `settings` in a field, you would make a class like this example:

```
use jrmadsen67\MahanaBitfield\MahanaBitfield;

class UserSettings extends MahanaBitfield
{
    public $flags = [
        'flag1' => 0,
        'flag2' => 1,
        'flag3' => 2,
    ];
}

```

Notice that this DOES NOT work directly with your model; you will have to get/set the `settings` field yourself in a normal manner for your framework or code.

To initialize a class:

`$mbf = new UserSettings;`

To set a particular flag to true/false

`$mbf->flag1 = true;`

To get a particular setting value

`$flag1  = $mbf->flag1;`

To get the bitmask value

`$settings = $mbf->getValue();`

Use setFlags() &amp; getFlags() to work with the whole array at once

```
$userSettings = new UserSettings;

$userSettings->setFlags([
    'flag2' => true,
    'flag3' => true,
]);

```

or

```
$setting_array = $userSettings->getFlags();

/*

var_dump($setting_array);

array(
    'flag2' => true,
    'flag3' => true,
);

*/

```

The tests can provide you with more examples. Questions and PRs welcome!

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3560d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/68a4d9bb38657f2c9360f5e953323185bde37c17a22e38848215a876e399e9bd?d=identicon)[jrmadsen67](/maintainers/jrmadsen67)

---

Top Contributors

[![jrmadsen67](https://avatars.githubusercontent.com/u/821958?v=4)](https://github.com/jrmadsen67 "jrmadsen67 (22 commits)")

---

Tags

Settingsbit masking

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jrmadsen67-mahana-bitmask/health.svg)

```
[![Health](https://phpackages.com/badges/jrmadsen67-mahana-bitmask/health.svg)](https://phpackages.com/packages/jrmadsen67-mahana-bitmask)
```

###  Alternatives

[glorand/laravel-model-settings

Model Settings for your Laravel app

9141.1M4](/packages/glorand-laravel-model-settings)[akaunting/laravel-setting

Persistent settings package for Laravel

490857.9k7](/packages/akaunting-laravel-setting)[outl1ne/nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.

298984.3k3](/packages/outl1ne-nova-settings)[chillerlan/php-settings-container

A container class for immutable settings objects. Not a DI container.

3432.2M22](/packages/chillerlan-php-settings-container)[pheme/yii2-settings

Yii2 Database settings

149753.2k7](/packages/pheme-yii2-settings)[bakerkretzmar/nova-settings-tool

A Laravel Nova tool to manage application settings.

164221.7k](/packages/bakerkretzmar-nova-settings-tool)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
