PHPackages                             berg/authorize - 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. berg/authorize

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

berg/authorize
==============

A package for basic ACL/role

0.1.1(10y ago)085MITPHPPHP &gt;=5.4.0

Since May 6Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mrberggg/authorizer)[ Packagist](https://packagist.org/packages/berg/authorize)[ Docs](https://github.com/mrberggg/authorizer)[ RSS](/packages/berg-authorize/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/4d0acd116283d78c3ce60ff34da023862c319c48bbdc31d4fe1eb22d5493f906/68747470733a2f2f7472617669732d63692e6f72672f6d726265726767672f617574686f72697a65722e737667)](https://travis-ci.org/mrberggg/authorizer)

Authorizer
==========

[](#authorizer)

A super simple role-based authorization package. The examples here use Eloquent but the library is framework-agnostic.

Installation
============

[](#installation)

`composer require berg/authorizer`

Usage
-----

[](#usage)

Add the use statement for the trait to your user model:

```
use Berg\Authorizer\AuthorizerTrait;

```

This trait requires that the user class has a method named `getRoles()` that will return an array of your role names. You can then access the `is` and `hasAccessTo` methods. Usage:

```
$user->is('admin');

$model = new ModelName($id);
$user->hasAccessTo($model);

```

`is` and `hasAccessTo` both return a boolean value. `hasAccessTo` requires that the model you pass as an argument contains a method `authorize(User $user);`.

### `is(string $roleName)`

[](#isstring-rolename)

Example checking role:

```
if($user->is('admin')) {}

```

### `hasAccessTo(User $user)`

[](#hasaccesstouser-user)

To make a model authorizable, add the `Authorizable` interface to your model. This interface requires you add a single method, `authorize($user)` to your model. Add any required authorization logic in that method and return a boolean value.

```
class Car
{
    public function authorize(User $user)
    {
        return $this->userId === $user->id;
    }
}

$carId = 1;
$car = new Car($carId);
if($user->hasAccessTo($car)) {}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

3876d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c27b8862c4219474522de47d039dab93624e161107c47a7b4c74aa1c227a1448?d=identicon)[mrberggg](/maintainers/mrberggg)

---

Tags

phpaclauthorize

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/berg-authorize/health.svg)

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

###  Alternatives

[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.4M43](/packages/santigarcor-laratrust)[shanmuga/laravel-entrust

This package provides a flexible solution to add ACL to Laravel

68312.9k2](/packages/shanmuga-laravel-entrust)[swoft/auth

Auth component for swoft

127.2k1](/packages/swoft-auth)[nahid/permit

Permit is a laravel ACL and authorization package

732.9k](/packages/nahid-permit)

PHPackages © 2026

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