PHP code example of curlymoustache / sanction

1. Go to this page and download the library: Download curlymoustache/sanction 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/ */

    

curlymoustache / sanction example snippets


 # rules.config.php

return [
    'standard_user' => [
        'permissions' => [
            'create_users',
            'update_users',
        ],
    ],
    'admin' => [
        'permissions' => [
            'delete_users',
        ],
        'inherits_from' => ['standard_user']
    ],
];


use Curlymoustache\Sanction\Sanction;
use Curlymoustache\Sanction\RoleLookup\SanctionArrayLookupProvider;

$rules = es' => ['admin']
    ],
    [
        'uid' => 32,
        'name' => 'Bones',
        'roles' => ['standard_user']
    ],
];


$sanction = new Sanction(
    $rules,
    null,
    new SanctionArrayLookupProvider( // A simple array lookup class.
        $users,
        'uid' // Use `uid` as the unique user_id
    )
);

// Now we can test these permissions to see if our rules hold true:

// Bones should be able to create users;
$sanction->userHasPermission(32, 'create_users'); // TRUE

// But not delete them:
$sanction->userHasPermission(32, 'delete_users'); // FALSE

// Where as Jim can delete them:
$sanction->userHasPermission(10, 'delete_users'); // TRUE


'Curlymoustache\Sanction\SanctionServiceProvider'

'Sanction' => 'Curlymoustache\Sanction\SanctionFacade',



use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

    use Curlymoustache\Sanction\Extensions\EloquentExtension;

...

$sanction->getCacheProvider()->delete();

$ php composer.phar <command>

php artisan config:publish curlymoustache/sanction

$ php artisan migrate --package="curlymoustache/sanction"

$ php artisan sanction:cleanup