PHPackages                             sokil/php-bitmap - 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. sokil/php-bitmap

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

sokil/php-bitmap
================

Bitmap representation with bitwise operations

2.0(5y ago)124.0k2[2 issues](https://github.com/sokil/php-bitmap/issues)2MITPHPPHP &gt;=7.1

Since Jan 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sokil/php-bitmap)[ Packagist](https://packagist.org/packages/sokil/php-bitmap)[ RSS](/packages/sokil-php-bitmap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (2)

php-bitmap
==========

[](#php-bitmap)

[![Total Downloads](https://camo.githubusercontent.com/d4196c3b124a1346c2c588085fc323909d4df4425cef0407d72bd5a7a6e9dd98/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6b696c2f7068702d6269746d61702e7376673f31)](https://packagist.org/packages/sokil/php-bitmap/stats)[![Daily Downloads](https://camo.githubusercontent.com/91b084027f2c037ef46be79078242f05fde2dd089639d83da4d3e6d290f02fcd/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d6269746d61702f642f6461696c79)](https://packagist.org/packages/sokil/php-bitmap/stats)[![Build](https://github.com/sokil/php-bitmap/workflows/Test/badge.svg?branch=master)](https://github.com/sokil/php-bitmap/actions?query=workflow%3ATest)

Bitmap, also called bit array is a data structure that compactly store set of values as bits of integer. More data can be read at [http://en.wikipedia.org/wiki/Bit\_array](http://en.wikipedia.org/wiki/Bit_array).

It is useful when required compact way to represent combination of values and simple manipulations with them. One byte can represent eight independent values.

### Installation

[](#installation)

```
composer require sokil/php-bitmap

```

### Useage

[](#useage)

Lets see example. Errors in PHP represents as constants:

```
E_ERROR = 1 (0);
E_WARNING = 2 (1);
E_PARSE = 4 (2);
E_NOTICE = 8 (3);
E_CORE_ERROR = 16 (4);
E_CORE_WARNING = 32 (5);
E_COMPILE_ERROR = 64 (6);
E_COMPILE_WARNING = 128 (7);
E_USER_ERROR = 256 (8);
E_USER_WARNING = 512 (9);
E_USER_NOTICE = 1024 (10);
E_STRICT = 2048 (11);
E_RECOVERABLE_ERROR = 4096 (12);
E_DEPRECATED = 8192 (13);
E_USER_DEPRECATED = 16384 (14);
E_ALL = 32767 (15);

```

Every error level represent logical "1", and combination of all this values may be represent only by two bytes. E\_ERROR represent first bit of byte, E\_WARNING - second, etc.

Combination of E\_WARNING and E\_NOTICE in binary system is "1010" or 10 in decimal system.

Class that represents bitmap of PHP errors:

```
class PhpError extends \Sokil\Bitmap
{
    /**
     * Show errors
     * Set first bit, which represents E_ERROR, to "1"
     */
    public function showErrors()
    {
        $this->setBit(0);
        return $this;
    }

    /**
     * Hide errors
     * Set first bit, which represents E_ERROR, to "0"
     */
    public function hideErrors()
    {
        $this->unsetBit(0);
        return $this;
    }

    /**
     * Check if errors shown
     * Check if first bit set to 1
     */
    public function isErrorsShown()
    {
        return $this->isBitSet(0);
    }

    /**
     * Show warnings
     * Set second bit, which represents E_WARNING, to "1"
     */
    public function showWarnings()
    {
        $this->setBit(1);
        return $this;
    }

    /**
     * Hide warnings
     * Set second bit, which represents E_WARNING, to "0"
     */
    public function hideWarnings()
    {
        $this->unsetBit(1);
        return $this;
    }

    /**
     * Check if warnings shown
     * Check if second bit set to 1
     */
    public function isWarningsShown()
    {
        return $this->isBitSet(1);
    }
}
```

Now we can easely manipulate with errors:

```
// load current error levels
$error = new PhpError(error_reporting());

// enable errors and warnings
$error->showErrors()->showWarnings();

// set error reporting
error_reporting($error->toInt());

// check if warnings shown
var_dump($error->isWarningsShown());

// value may be set by mask
// E_USER_ERROR | E_USER_WARNING is 256 + 512;
$error->setBitsByMask(E_USER_ERROR | E_USER_WARNING);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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

Every ~610 days

Total

4

Last Release

1945d ago

Major Versions

0.2 → 1.12018-02-23

1.1 → 2.02021-01-19

PHP version history (2 changes)1.1PHP &gt;=5.3

2.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/902e21ecf6517341b1f2a3c2f93a3eb115396fc6524effaeabc816b481909e64?d=identicon)[sokil](/maintainers/sokil)

---

Top Contributors

[![sokil](https://avatars.githubusercontent.com/u/1829948?v=4)](https://github.com/sokil "sokil (32 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")

---

Tags

binarybitarraybitmapbitmaskmaskphpbitmap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sokil-php-bitmap/health.svg)

```
[![Health](https://phpackages.com/badges/sokil-php-bitmap/health.svg)](https://phpackages.com/packages/sokil-php-bitmap)
```

###  Alternatives

[byte5/laravel-passgenerator

A Laravel package to create Apple Wallet (old Passbook) compatible tickets.

8821.3k](/packages/byte5-laravel-passgenerator)[soyhuce/next-ide-helper

Laravel ide helper rebuilt under steroids

4756.2k3](/packages/soyhuce-next-ide-helper)[usu/codice-fiscale

A library to calculate and check the validity of the italian fiscal code (codice fiscale)

23170.9k1](/packages/usu-codice-fiscale)[kzykhys/steganography

Simple implementation of Steganography (Hiding a hidden message within an image)

889.7k](/packages/kzykhys-steganography)[jxlwqq/watermark

generate text watermark with canvas

1014.8k](/packages/jxlwqq-watermark)

PHPackages © 2026

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