PHP code example of vortexpanel / policy-permission-sync

1. Go to this page and download the library: Download vortexpanel/policy-permission-sync library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vortexpanel / policy-permission-sync example snippets


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

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

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

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

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

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

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

'policy_paths' => [app_path('Policies')],
bash
php artisan vendor:publish --tag=policy-permission-sync-config
bash
php artisan permissions:sync-policies --dry-run
bash
php artisan permissions:sync-policies
bash
php artisan permissions:sync-policies --prune
bash
php artisan permissions:sync-policies --guards=web,api
bash
php artisan permissions:sync-policies --only=posts,users
php artisan permissions:sync-policies --except=audits
bash
php artisan permissions:sync-policies