PHPackages                             i74ifa/role-craft - 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. i74ifa/role-craft

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

i74ifa/role-craft
=================

automating role creation and permission management with Spatie/Laravel-Permission.

v2.2.0(1mo ago)4352MITPHPPHP ^8.4

Since Jan 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/i74ifa/role-craft)[ Packagist](https://packagist.org/packages/i74ifa/role-craft)[ Docs](https://github.com/i74ifa/role-craft)[ RSS](/packages/i74ifa-role-craft/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (12)Versions (12)Used By (0)

Role-Craft for spatie/laravel-permission
========================================

[](#role-craft-for-spatielaravel-permission)

[![Latest Version on Packagist](https://camo.githubusercontent.com/70d5def4896f6e93239c4a47ea1dd2681fc57f57a3ae602675d394368984fbd7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6937346966612f726f6c652d63726166742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/i74ifa/role-craft)[![Total Downloads](https://camo.githubusercontent.com/06ae82870b0406fa1afa373d2bc9a872e0cb7788db81736a8d96d699c46d8238/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6937346966612f726f6c652d63726166742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/i74ifa/role-craft)[![GitHub Actions](https://github.com/i74ifa/role-craft/actions/workflows/main.yml/badge.svg)](https://github.com/i74ifa/role-craft/actions/workflows/main.yml/badge.svg)

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

[](#installation)

```
composer require i74ifa/role-craft
```

Version Compatibility
---------------------

[](#version-compatibility)

VersionLaravelSpatie PermissionPHP**v2.x**12.0+ / 13.0+7.0+8.4+**v1.x**10.0+ / 11.0+6.x8.2+### optional

[](#optional)

publish config

```
php artisan vendor:publish --tag=role-craft-config
```

### AI agent guide

[](#ai-agent-guide)

This package ships an agent-neutral usage guide for AI coding assistants at:

```
vendor/i74ifa/role-craft/docs/AGENT_GUIDE.md

```

It covers every config key, command flag, per-model override, naming rule, and common recipe in one place. It is plain Markdown — readable by humans and by any agent (Cursor, Cline, Aider, GitHub Copilot, Codex, Claude Code, etc.).

To make your agent pick it up automatically, reference the path from whichever rules file your tool uses, for example:

- `AGENTS.md` (Codex / generic) — link or include the file.
- `.cursor/rules/*.mdc` (Cursor) — `@vendor/i74ifa/role-craft/docs/AGENT_GUIDE.md`.
- `.github/copilot-instructions.md` (GitHub Copilot) — link to the file.
- `CLAUDE.md` or `.claude/skills/role-craft/SKILL.md` (Claude Code) — link to or copy the file.
- `.clinerules`, `.windsurfrules`, `.continuerules` — reference the file path.

Usage
-----

[](#usage)

### Generate role and Permissions

[](#generate-role-and-permissions)

```
php artisan role-craft:generate
```

this command will be generate all permissions and `role-craft.default_role` will be created if you want to change default role name, you can change it in config/role-craft.php after publish config

### Sync permissions

[](#sync-permissions)

```
php artisan role-craft:sync manager --all
```

this will be sync all permissions to `manager` role if it exists if not exists you want to use `--create` option

```
php artisan role-craft:sync manager --create
```

if you want to sync some role from models use `--models` option

```
php artisan role-craft:sync manager --models=User --models=Post

# OR Custom Directory
php artisan role-craft:sync manager --models=App\Models\Directory\User
```

Generate role if not exists

```
php artisan role-craft:sync manager --create
```

### Including models (whitelist)

[](#including-models-whitelist)

Some projects don't need permissions for every model in `app/Models`. To restrict scanning to a curated set, fill `included_models` in `config/role-craft.php`. When the list is non-empty, role-craft **only** processes models matching one of the patterns — everything else is treated as "excluded all":

```
// config/role-craft.php

'included_models' => [
    App\Models\User::class,          // exact class
    'App\Models\Billing\*',          // whole subtree
    '*\Public\*',                    // any "Public" folder anywhere
],
```

When `included_models` is empty (the default), every Eloquent model under `models_path` is included.

### Excluding models (blacklist)

[](#excluding-models-blacklist)

If you want to skip one or more models, add them to the `excluded_models` array. Excludes are applied **after** the include filter, so you can whitelist a subtree and then carve a few classes out of it:

```
// config/role-craft.php

'excluded_models' => [
    App\Models\User::class,          // exact class
    'App\Models\Internal\*',         // every model under app/Models/Internal
    '*\Pivot\*',                     // any "Pivot" folder anywhere
],
```

Notes:

- Both filters use `fnmatch` on the fully-qualified class name (leading backslashes are normalized).
- The filters are only applied during directory scans. Passing `--models=Foo` explicitly still includes `Foo` — user intent wins.
- Order of operations: `included_models` first (if non-empty), then `excluded_models`.

### Per-model customization

[](#per-model-customization)

Override the permission name or action list on a specific model by declaring public properties on it:

```
class Post extends Model
{
    // Replaces the table-name segment in the permission name
    public $prefix_permissions = 'blog_posts';

    // Replaces the default action list for this model
    public $prefix_model_permissions = ['create', 'view', 'publish', 'archive'];
}
```

License
-------

[](#license)

This package is released under the [MIT license](https://github.com/i74ifa/role-craft/blob/main/LICENSE).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~47 days

Recently: every ~89 days

Total

11

Last Release

44d ago

Major Versions

v1.1.4 → v2.0.02026-03-28

PHP version history (4 changes)1.0.0PHP ^8.2

1.0.1PHP ^8.1

1.0.3PHP ^8.3

v2.0.1PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/1703357a40c48453eeb972fd2297ed8b545fa001843f863c43443c137f220150?d=identicon)[74ifa](/maintainers/74ifa)

---

Top Contributors

[![i74ifa](https://avatars.githubusercontent.com/u/69402911?v=4)](https://github.com/i74ifa "i74ifa (18 commits)")[![hothaifadev](https://avatars.githubusercontent.com/u/139741620?v=4)](https://github.com/hothaifadev "hothaifadev (3 commits)")

---

Tags

spatielaravelpermissionrolelaravel-permissioni74ifarole-craft

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/i74ifa-role-craft/health.svg)

```
[![Health](https://phpackages.com/badges/i74ifa-role-craft/health.svg)](https://phpackages.com/packages/i74ifa-role-craft)
```

###  Alternatives

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k3.9M130](/packages/bezhansalleh-filament-shield)[althinect/filament-spatie-roles-permissions

3481.1M10](/packages/althinect-filament-spatie-roles-permissions)

PHPackages © 2026

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