PHPackages                             vortexpanel/policy-permission-sync - 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. vortexpanel/policy-permission-sync

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

vortexpanel/policy-permission-sync
==================================

Sync Laravel Policies to Spatie permissions using dot-style naming.

v1.0.0(5mo ago)042MITPHPPHP ^8.1CI passing

Since Jan 19Pushed 5mo agoCompare

[ Source](https://github.com/viryl15/policy-permission-sync)[ Packagist](https://packagist.org/packages/vortexpanel/policy-permission-sync)[ RSS](/packages/vortexpanel-policy-permission-sync/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

VortexPanel — Policy Permission Sync
====================================

[](#vortexpanel--policy-permission-sync)

Sync Laravel **Policies** into **Spatie permissions** using deterministic names (configurable):

- `posts.view_any`
- `posts.view`
- `posts.create`
- `posts.update`
- `posts.delete`

This is a tiny, UI-agnostic package intended to be reused by admin panels (VortexPanel, Filament, Nova, ...).

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10+
- `spatie/laravel-permission`

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

[](#installation)

```
composer require vortexpanel/policy-permission-sync
```

Publish config:

```
php artisan vendor:publish --tag=policy-permission-sync-config
```

Configuration
-------------

[](#configuration)

Edit `config/policy-permission-sync.php`.

The most reliable setup is to explicitly scan your policies directory:

```
'policy_paths' => [
    app_path('Policies'),
],
```

### Customize permission naming

[](#customize-permission-naming)

By default, permissions are created using a dot-style pattern:

```
'naming' => [
    'prefix' => '',
    'pattern' => '{resource}.{ability}',
],
```

You can change it to any pattern containing `{resource}` and `{ability}`:

```
// posts:view_any
'pattern' => '{resource}:{ability}',

// view_any:posts
'pattern' => '{ability}:{resource}',

// admin.posts.view_any
'prefix' => 'admin.',
'pattern' => '{resource}.{ability}',
```

Notes:

- If you use `--prune`, the package scopes pruning by extracting `{resource}` back from permission names using this same pattern. If your pattern doesn't include `{resource}`, pruning can't be scoped.

If your policies live in a custom directory/namespace, set the mapping:

```
'policy_paths' => [
    app_path('Domain/Blog/Policies'),
],

'policy_path_namespace_map' => [
    app_path('Domain/Blog/Policies') => 'App\\Domain\\Blog\\Policies',
],
```

Usage
-----

[](#usage)

Preview changes (no DB writes):

```
php artisan permissions:sync-policies --dry-run
```

Apply changes:

```
php artisan permissions:sync-policies
```

Prune stale permissions (**opt-in**):

```
php artisan permissions:sync-policies --prune
```

Target specific guards:

```
php artisan permissions:sync-policies --guards=web,api
```

Filter resources:

```
php artisan permissions:sync-policies --only=posts,users
php artisan permissions:sync-policies --except=audits
```

Show per-permission actions:

```
php artisan permissions:sync-policies --details
# or use artisan verbosity:
php artisan permissions:sync-policies -v
```

Development &amp; Tests (inside this package repo)
--------------------------------------------------

[](#development--tests-inside-this-package-repo)

If you see `PDOException: could not find driver`, your PHP CLI is missing the SQLite extension.

**Ubuntu/WSL:**

```
sudo apt-get update
sudo apt-get install -y php-sqlite3
php -m | grep -i sqlite
```

Then:

```
composer install
composer test
composer analyse
```

Testing in a real Laravel app (manual)
--------------------------------------

[](#testing-in-a-real-laravel-app-manual)

1. Install `spatie/laravel-permission` and run its migrations.
2. Create a policy, e.g. `app/Policies/PostPolicy.php` with methods like `viewAny`, `view`, `create`, `update`, `delete`.
3. Ensure your config scans the right directory:

```
'policy_paths' => [app_path('Policies')],
```

4. Run:

```
php artisan permissions:sync-policies
```

Then check the `permissions` table.

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b3dd8eaf671d37db5661aaad007559f25f76e3ce7ef378f3489e17940f9206c?d=identicon)[viryl15](/maintainers/viryl15)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vortexpanel-policy-permission-sync/health.svg)

```
[![Health](https://phpackages.com/badges/vortexpanel-policy-permission-sync/health.svg)](https://phpackages.com/packages/vortexpanel-policy-permission-sync)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[laravel/folio

Page based routing for Laravel.

603583.7k33](/packages/laravel-folio)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4925.3k](/packages/erag-laravel-lang-sync-inertia)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725173.0k14](/packages/tallstackui-tallstackui)

PHPackages © 2026

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