PHPackages                             napp/aclcore - 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. napp/aclcore

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

napp/aclcore
============

ACL core for projects

2.0.0(5y ago)31.3k1MITPHPPHP ^7.2|^8.0

Since Sep 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Napp/aclcore)[ Packagist](https://packagist.org/packages/napp/aclcore)[ RSS](/packages/napp-aclcore/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (9)Versions (8)Used By (1)

Napp ACL Core
=============

[](#napp-acl-core)

[![Build Status](https://camo.githubusercontent.com/0dc70ad800459d549e6ee62911ac25b79c5f0dbcf057e5b9082003566a2c4316/68747470733a2f2f7472617669732d63692e6f72672f4e6170702f61636c636f72652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Napp/aclcore)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e5dc3293e84e531b467d2d1815cc16d025c26487cb3bb80256d6215d99baa13a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6170702f61636c636f72652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Napp/aclcore/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e2330e920db1d4af69ae0ff27a33c7e65feec320071f7ea8d72b533e13ce3c13/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e6170702f61636c636f72652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Napp/aclcore/?branch=master)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![codecov](https://camo.githubusercontent.com/ee2ad2e5210b73367d203a6a77f4677753c25e63edf429b9092c48e820001bb9/68747470733a2f2f636f6465636f762e696f2f67682f4e6170702f61636c636f72652f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d303873424e7942764152)](https://codecov.io/gh/Napp/aclcore/branch/master)

Roles and Permissions for Laravel optimized for performance. Every permission is registered through code instead of pivot tables. This results in great performance.

Install
-------

[](#install)

```
composer require napp/aclcore
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Napp\Core\Acl\AclServiceProvider" --tag="config"
```

When published - then review it and change accordingly to your applications. The config files `config/acl.php` contains:

```
return [
    /**
     * Define which Eloquent models used by the package
     */
    'models' => [
        'role' => Napp\Core\Acl\Model\Role::class,
        'user' => Illuminate\Foundation\Auth\User::class,
    ],

    /**
     * Table names for the package
     */
    'table_names' => [
        'roles' => 'roles',
        'users_roles' => 'users_roles',
    ],

    /**
     * The default guard used to authorize users
     */
    'guard' => 'web'
];
```

Usage
-----

[](#usage)

Add `HasRole` trait to your User model:

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Napp\Core\Acl\Contract\Role as RoleContract;
use Napp\Core\Acl\Role\HasRole;

class User extends Authenticatable implements RoleContract
{
    use HasRole;
}
```

### Register Permissions

[](#register-permissions)

Register simple permissions in your app.

```
Napp\Core\Acl\PermissionRegistrar::register([
    'users.create',
    'users.view'
]);
```

Register permissions with Closure.

```
Napp\Core\Acl\PermissionRegistrar::register([
    'users.create' => 'My\App\Users\Permissions@create',
    'users.update' => 'My\App\Users\Permissions@edit',
    'users.view'
]);
```

### Register Middleware

[](#register-middleware)

Add the middleware to `App/Http/Kernal.php`

```
protected $routeMiddleware = [
    'may' => \Napp\Core\Acl\Middleware\Authorize::class,
```

usage:

```
Route::get('users', ['uses' => 'UsersController@index'])->middleware('may:users.view');
```

### Usage in php code

[](#usage-in-php-code)

```
// authorize a single permission
if (may('users.view')) {
    // do something
}

// authorize if **any** of the permissions are valid
if (may(['users.view', 'users.create'])) {
    // do something
}

// authorize if **all** of the permissions are valid
if (mayall(['users.view', 'users.create'])) {
    // do something
}

// reverse - not logic
if (maynot('users.view')) {
    return abort();
}

// check for user role
if (has_role($user, 'manager')) {
    // do something
}

// check if user has many roles
if (has_role($user, ['support', 'hr'])) {
    // do something
}
```

### Usage in Blade

[](#usage-in-blade)

`may` is equivalent to default `can` from Laravel.

```
@may('users.create')
    Create
@endmay
```

Check if user has **any** of the permissions

```
@may(['users.create', 'users.update'])
    Create
@endmay
```

Check if user have **all** of the permissions

```
@mayall(['users.create', 'users.update'])
    Create
@endmayall
```

Use `maynot` for reverse logic

```
@maynot('users.create')
    Create
@endmaynot
```

Check if user has a specific role

```
@hasrole('admin')
    Create
@endhasrole
```

See PHPUnit tests for more examples and usage.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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

Every ~131 days

Recently: every ~196 days

Total

7

Last Release

2023d ago

Major Versions

1.1.2 → 2.0.02020-10-29

PHP version history (2 changes)1.0.0PHP &gt;=7.1

2.0.0PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e24155f0d3ab61799ca35477a940edce613075a20d1073f2241905271f29d23?d=identicon)[viezel](/maintainers/viezel)

---

Top Contributors

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

---

Tags

acllaravelnappperformancepermissionsrolesaclrolespermissionsnapp

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/napp-aclcore/health.svg)

```
[![Health](https://phpackages.com/badges/napp-aclcore/health.svg)](https://phpackages.com/packages/napp-aclcore)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[hasinhayder/tyro

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

6712.1k2](/packages/hasinhayder-tyro)[beatswitch/lock-laravel

A Laravel Driver for Lock.

15529.1k1](/packages/beatswitch-lock-laravel)[yajra/laravel-acl

Laravel ACL is a simple role, permission ACL for Laravel Framework.

112103.9k1](/packages/yajra-laravel-acl)[directorytree/authorization

Native Laravel Authorization.

1809.5k](/packages/directorytree-authorization)

PHPackages © 2026

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