Download the PHP package din9xtr/laravel-enum-permissions without Composer
On this page you can find all versions of the php package din9xtr/laravel-enum-permissions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download din9xtr/laravel-enum-permissions
More information about din9xtr/laravel-enum-permissions
Files in din9xtr/laravel-enum-permissions
Package laravel-enum-permissions
Short Description Laravel permission management system using PHP Enums
License MIT
Homepage https://github.com/din9xtr/laravel-enum-permissions
Informations about the package laravel-enum-permissions
Laravel Enum Permissions
[]()
Type-safe permission management system for Laravel models using PHP backed enums.
Installation
Storage formats
The package supports two storage formats:
- JSON: default and backward compatible with
PermissionsCast. - HEX: compact bitmask storage with
HexPermissionsCast.
Existing users can keep PermissionsCast::class unchanged. New projects may choose HEX explicitly in the model cast.
Migrations
JSON
Use JSON when readability and direct database inspection matter.
JSON is stored as an object keyed by permission enum values:
HEX
Use HEX when compact storage is preferred.
HEX is stored as a deterministic bitmask. Bit 0 maps to the first PermissionEnum::cases() item, bit 1 maps to the second item, and so on. For example, if CREATE, READ, and EXPORT are enabled, the stored value is 13.
For HEX storage, the order of permission enum cases is part of the persisted data format. Append new permissions to the enum when possible. Reordering or inserting cases in the middle changes the meaning of existing stored HEX values and requires a data migration.
Enums
PackageEnum is optional unless you use applyPackage() or detectPackage(). When used with the trait, it must define a CUSTOM case.
Model configuration
JSON cast
HEX cast
Usage
The cast returns a PermissionsCollection:
Compatibility and edge cases
PermissionsCastkeeps the original JSON behavior and remains the default recommendation for existing projects.HexPermissionsCastis opt-in and does not read JSON values automatically.null, an empty JSON value, an empty HEX value,0, and0x0are treated as all permissions disabled.- Unknown JSON permission keys are ignored on read and are not written back.
- HEX bits beyond the current enum cases are ignored on read and are not written back.
- Invalid HEX strings are treated as
0. - Missing known permissions are normalized to
false.
Requirements
- PHP 8.3 or higher
- Laravel 11.x components
Development
The Composer archive excludes tests and development tooling, so production installs receive only the library files and package metadata.
License
This project is open-source and available under the MIT License.
Copyright © 2026 Din9xtr
All versions of laravel-enum-permissions with dependencies
illuminate/contracts Version ^11.0
illuminate/database Version ^11.0
illuminate/support Version ^11.0