PHPackages                             muhammadtashfeen/lara-authpem - 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. muhammadtashfeen/lara-authpem

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

muhammadtashfeen/lara-authpem
=============================

A package that makes settings permissions and authorizations easier in Laravel.

v1.0.1(8mo ago)02MITPHPPHP ^8.3CI passing

Since Aug 17Pushed 8mo agoCompare

[ Source](https://github.com/muhammadtashfeen/lara-authpem)[ Packagist](https://packagist.org/packages/muhammadtashfeen/lara-authpem)[ RSS](/packages/muhammadtashfeen-lara-authpem/feed)WikiDiscussions master Synced 1mo ago

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

🚀 LaraAuthpem
=============

[](#-laraauthpem)

**LaraAuthpem** is a Laravel package for **flexible role &amp; permission management**, bringing **attribute-based access control** to your Laravel applications.
With LaraAuthpem, you can easily protect routes, controllers, and actions by simply attaching PHP attributes. 🛡️

[![Tests](https://github.com/muhammadtashfeen/lara-authpem/actions/workflows/tests.yml/badge.svg)](https://github.com/muhammadtashfeen/lara-authpem/actions/workflows/tests.yml/badge.svg)

---

✨ Features
----------

[](#-features)

- 🔑 Assign multiple roles &amp; permissions to users
- ⚡ Middleware for automatic role &amp; permission checks
- 🧩 Attribute-based access control with PHP 8+ attributes
- 🔒 Protect routes and controllers with minimal boilerplate
- 🛠️ Simple integration with Laravel authentication
- 📦 Service classes to handle role &amp; permission logic

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require muhammadtashfeen/lara-authpem
```

(Optional) Publish the service provider:

```
php artisan vendor:publish --provider="MuhammadTashfeen\LaraAuthpem\Providers\AuthServiceProvider"
```

---

🔑 User Model Requirements
-------------------------

[](#-user-model-requirements)

Your `User` model **must implement** the following methods:

```
public function getRoles(): array
{
    return ['admin', 'editor']; // example
}

public function getPermissions(): array
{
    return ['view_users', 'create_users']; // example
}
```

> ⚡ How these arrays are populated is **entirely up to you** — they can come from the database, config, or any custom logic.
> The important part is that they **always return arrays** of role names and permission names.

---

🚀 Usage
-------

[](#-usage)

### 🛡️ Middleware Protection

[](#️-middleware-protection)

Use the middleware alias `mt.authpem` to protect routes:

```
Route::middleware(['mt.authpem'])->group(function () {
    Route::get('/users', [UserController::class, 'index']);
});
```

### 🧩 Attribute Usage (Controller-Level)

[](#-attribute-usage-controller-level)

```
use MuhammadTashfeen\LaraAuthpem\Attributes\HasRole;
use MuhammadTashfeen\LaraAuthpem\Attributes\HasPermission;

#[HasRole('admin')]
#[HasPermission('view_users')]
public function index() {
    // Only accessible by admins with view_users permission
}
```

---

🧪 Testing
---------

[](#-testing)

Run PHPUnit tests:

```
vendor/bin/phpunit
```

---

⚙️ Compatibility
----------------

[](#️-compatibility)

- PHP: ^8.3
- Laravel: 10.x
- PHPUnit: ^11.0 (for testing)
- Orchestra Testbench: ^9.5 (for testing)
- Laravel Pint: dev-main (optional, for code style)

---

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome!
Feel free to open issues or submit PRs to improve LaraAuthpem.

---

📄 License
---------

[](#-license)

LaraAuthpem is open-sourced software licensed under the **MIT license**.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance58

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~0 days

Total

2

Last Release

268d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2eaf6aadfa7bfdb03ae291ab95bcffd1cccd2b1f9fa2bee182cb6924c53e57b0?d=identicon)[muhammadtashfeen](/maintainers/muhammadtashfeen)

---

Top Contributors

[![muhammadtashfeen](https://avatars.githubusercontent.com/u/33387995?v=4)](https://github.com/muhammadtashfeen "muhammadtashfeen (6 commits)")[![muhammad-gaia](https://avatars.githubusercontent.com/u/82645516?v=4)](https://github.com/muhammad-gaia "muhammad-gaia (5 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/muhammadtashfeen-lara-authpem/health.svg)

```
[![Health](https://phpackages.com/badges/muhammadtashfeen-lara-authpem/health.svg)](https://phpackages.com/packages/muhammadtashfeen-lara-authpem)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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