PHPackages                             henry-ht/laravel-bitwise-permission - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. henry-ht/laravel-bitwise-permission

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

henry-ht/laravel-bitwise-permission
===================================

A fast, database-light bitwise permission system for Laravel — roles, permissions, routes and menus with an optional Livewire admin UI.

1.1.00(1mo ago)00MITPHPPHP ^8.2

Since Jun 25Pushed 1mo agoCompare

[ Source](https://github.com/henry-ht/laravel-bitwise-permission)[ Packagist](https://packagist.org/packages/henry-ht/laravel-bitwise-permission)[ Docs](https://bitwise.tchenry.com)[ RSS](/packages/henry-ht-laravel-bitwise-permission/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (8)Versions (22)Used By (0)

 [![Laravel Bitwise Permission](https://camo.githubusercontent.com/b9fb4bc589bb0315db87c3b7fe89b13a02b1540f33b0ac05890f79c496f8c90e/68747470733a2f2f626974776973652e746368656e72792e636f6d2f6173736574732f696d672f6f672d696d6167652e706e67)](https://camo.githubusercontent.com/b9fb4bc589bb0315db87c3b7fe89b13a02b1540f33b0ac05890f79c496f8c90e/68747470733a2f2f626974776973652e746368656e72792e636f6d2f6173736574732f696d672f6f672d696d6167652e706e67)

Laravel Bitwise Permission
==========================

[](#laravel-bitwise-permission)

 A fast, database-light permission system for Laravel.
 Roles, permissions, routes and menus — resolved from a single integer, not a join table.

 [![Latest Version](https://camo.githubusercontent.com/425d0ab7d09dd777bf0fd1f7de7f1593f34ee59421e0fa3af87f080584c2f489/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68656e72792d68742f6c61726176656c2d626974776973652d7065726d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/henry-ht/laravel-bitwise-permission) [![Tests](https://camo.githubusercontent.com/36a454121a82af2bd8787718fa5db0db3da76650b2fdd4698b90f6352ffdb2ae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f68656e72792d68742f6c61726176656c2d626974776973652d7065726d697373696f6e2f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/henry-ht/laravel-bitwise-permission/actions) [![Total Downloads](https://camo.githubusercontent.com/101f856fc394a09a5606f20d1fe70e100900d1610ea8312f6be3e147308615ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68656e72792d68742f6c61726176656c2d626974776973652d7065726d697373696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/henry-ht/laravel-bitwise-permission) [![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![PHP](https://camo.githubusercontent.com/5e9de427979d2fb21be4f23d72ab2f585ee3a5d385179fe54a2db5742e53181d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737376262342e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/5e9de427979d2fb21be4f23d72ab2f585ee3a5d385179fe54a2db5742e53181d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d3737376262342e7376673f7374796c653d666c61742d737175617265) [![Laravel](https://camo.githubusercontent.com/e4f4474fd4421b9522d3ed1a544f8df3115cfd12083ff6293d45ea0e3c8dbdb3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3131253230253743253230313225323025374325323031332d6666326432302e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e4f4474fd4421b9522d3ed1a544f8df3115cfd12083ff6293d45ea0e3c8dbdb3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d3131253230253743253230313225323025374325323031332d6666326432302e7376673f7374796c653d666c61742d737175617265)

 **[Documentation](https://bitwise.tchenry.com)** · [Installation](https://bitwise.tchenry.com/docs/installation) · [Examples](https://bitwise.tchenry.com/docs/examples) · [Español](README.es.md)

---

Why bitwise?
------------

[](#why-bitwise)

Most permission packages store one database row per `role × permission × resource`. That works, but it grows fast and every authorization check becomes a query — or a cache you have to invalidate correctly.

A bitwise permission is a single integer. Every capability is a power of two, so any combination of capabilities is just one number:

```
view (1) + create (4) + update (8) = 13
```

Checking access is a CPU-level `AND` operation, not a database lookup:

```
$access & $bit === $bit   // true or false, no query
```

Laravel Bitwise Permission builds a complete authorization layer on top of that idea — **roles**, **per-route permissions**, **navigation menus**, and an optional **Livewire admin UI** — while keeping the core check as cheap as it can possibly be.

Features
--------

[](#features)

- 🔢 **Bitwise core** — combine and compare permissions with plain integer math, no runtime joins.
- 🧩 **Route-based permissions** — protect named routes with a wildcard convention (`leads.*`, `deals.*`).
- 🧭 **Menus with role visibility** — a self-managing navigation tree, including automatic parent/child propagation.
- 👑 **Super admin bypass** — a configured super admin role always has full access, without ever touching the database.
- 🧬 **Per-user roles** — `RoleCloneService` clones a base role per user, so individual permissions can diverge safely.
- 🖥️ **Optional Livewire UI** — manage roles, permissions, routes, accesses and menus from `/bwp/*` out of the box.
- ⚙️ **Artisan tooling** — `bwp:install`, `bwp:sync-routes` and `bwp:sync-base` get a project wired up in minutes.
- 🧱 **Config-first** — bits, base permissions, roles, routes and menus are all defined in one published config file.

Quick look
----------

[](#quick-look)

```
use HenryHt\BitwisePermission\Traits\HasPermissionsTrait;

class User extends Authenticatable
{
    use HasPermissionsTrait;
}
```

```
Route::middleware('bwp.permission:create')->group(function () {
    Route::post('/leads', [LeadController::class, 'store'])->name('leads.store');
});
```

```
@if(auth()->user()->canCreate())
    New lead
@endif

@if(auth()->user()->isSuperAdmin())
    Super Admin
@endif
```

```
$user->setPermission('leads.*', 'modify access');
$user->setMenuAccess('leads', true);
```

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

[](#installation)

```
composer require henry-ht/laravel-bitwise-permission
php artisan bwp:install
```

`bwp:install` publishes the config, migrations and assets, runs the migrations, and seeds the base roles, permissions and menus. See the [installation guide](https://bitwise.tchenry.com/docs/installation) for the manual, step-by-step version and for wiring up your `User` model.

### Syncing base data

[](#syncing-base-data)

After the initial install, you can re-sync base roles, routes and menus from the config at any time without duplicating existing records:

```
# Sync all (roles + routes + menus)
php artisan bwp:sync-base

# Sync only roles
php artisan bwp:sync-base --roles

# Sync only routes
php artisan bwp:sync-base --routes

# Sync only menus
php artisan bwp:sync-base --menus

# Combine options
php artisan bwp:sync-base --roles --routes
```

`bwp:sync-base` reads the `base_roles`, `base_routes` and `base_menus` arrays from `config/bitwise-permission.php`, creates new entries, updates changed ones and skips records that are already up to date. Menu role visibility (`bwp_menu_role`) is also refreshed automatically.

Documentation
-------------

[](#documentation)

Full documentation, including configuration reference, middleware usage, role and permission management, menu building, and real-world examples, lives at **[bitwise.tchenry.com](https://bitwise.tchenry.com)**.

GuideDescription[Installation](https://bitwise.tchenry.com/docs/installation)Requirements, install command, and manual setup[Configuration](https://bitwise.tchenry.com/docs/configuration)Bits, base permissions, super admin, table prefix[Middleware](https://bitwise.tchenry.com/docs/middleware)Protecting routes and the `view` prerequisite rule[Roles](https://bitwise.tchenry.com/docs/roles)Base roles, per-user roles, `RoleCloneService`[Permissions](https://bitwise.tchenry.com/docs/permissions)Checking, setting and combining permissions at runtime[Menus](https://bitwise.tchenry.com/docs/menus)Building navigation trees with role-based visibility[Examples](https://bitwise.tchenry.com/docs/examples)End-to-end flows: user creation, custom bits, Livewire[Upgrading](https://bitwise.tchenry.com/docs/upgrading)Version-to-version upgrade notesRequirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12 or 13
- Livewire 3 or 4 (only required if you use the bundled admin UI)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for a history of releases.

Contributing
------------

[](#contributing)

Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) before opening a pull request.

Security
--------

[](#security)

If you discover a security vulnerability, please review [SECURITY.md](SECURITY.md) for our disclosure process — do not open a public issue.

Credits
-------

[](#credits)

- [Henry HT](https://github.com/henry-ht) — [Facebook](https://www.facebook.com/thecreativehenry) · [Instagram](https://www.instagram.com/thecreativehenry/)
- [All contributors](https://github.com/henry-ht/laravel-bitwise-permission/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance93

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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 ~1 days

Total

21

Last Release

36d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf28e1a351743385aa2b77be899076beb65b5d378d3673f7ee99d9a50ca595bb?d=identicon)[henry-ht](/maintainers/henry-ht)

---

Tags

laravelauthorizationmenulivewireaclrolespermissionsbitwise

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/henry-ht-laravel-bitwise-permission/health.svg)

```
[![Health](https://phpackages.com/badges/henry-ht-laravel-bitwise-permission/health.svg)](https://phpackages.com/packages/henry-ht-laravel-bitwise-permission)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k4.3M166](/packages/bezhansalleh-filament-shield)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6796.8k7](/packages/hasinhayder-tyro)[shanmuga/laravel-entrust

This package provides a flexible solution to add ACL to Laravel

68346.9k2](/packages/shanmuga-laravel-entrust)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.8k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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