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(10mo ago)02MITPHPPHP ^8.3CI passing

Since Aug 17Pushed 10mo 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 today

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

31

—

LowBetter than 66% of packages

Maintenance54

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

321d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33387995?v=4)[muhammadtashfeen](/maintainers/muhammadtashfeen)[@muhammadtashfeen](https://github.com/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

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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