Download the PHP package fgremez/flagbag without Composer
On this page you can find all versions of the php package fgremez/flagbag. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download fgremez/flagbag
More information about fgremez/flagbag
Files in fgremez/flagbag
Download fgremez/flagbag
More information about fgremez/flagbag
Files in fgremez/flagbag
Vendor fgremez
Package flagbag
Short Description Manipulate bitmask integers as typed PHP objects
License MIT
Package flagbag
Short Description Manipulate bitmask integers as typed PHP objects
License MIT
Please rate this library. Is it a good library?
Informations about the package flagbag
FlagBag
A lightweight PHP library to manipulate bitmask integers as typed objects.
No dependencies. No framework required.
Installation
Requirements: PHP >= 8.1
Concept
Each flag is a power of 2. The stored value is the sum of active flags.
This allows efficient storage (a single integer column) and native SQL filtering:
Usage
1. Define a FlagBag
Extend FlagBag and declare your boolean properties with #[FlagBit].
Each value must be a power of 2.
2. Hydrate from an integer
3. Read a flag
4. Write a flag
5. Chaining
6. Integrate with any class
The column stays a plain integer — no custom ORM type needed.
Exceptions
| Exception | Thrown when |
|---|---|
UnknownFlagException |
get()/set() called with a flag name that does not exist |
InvalidFlagBitValueException |
A #[FlagBit] value is not a power of 2 |
FlagBitCollisionException |
Two properties share the same #[FlagBit] value |
Integer limits
| Storage | Size | Max flags | Max value |
|---|---|---|---|
| TINYINT | 8 bits | 7 | 127 |
| SMALLINT | 16 bits | 15 | 32 767 |
| INT | 32 bits | 31 | 2 147 483 647 |
| BIGINT | 64 bits | 62 | ~4.6×10¹⁸ |
License
MIT — see LICENSE
All versions of flagbag with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
The package fgremez/flagbag contains the following files
Loading the files please wait ...