PHP code example of delboy1978uk / bone-passport

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

    

delboy1978uk / bone-passport example snippets




// use statements here
use Bone\Passport\PassportPackage;
use Del\Passport\PassportPackage as DelPassportPackage;

return [
    'packages' => [
        // packages here...,
        DelPassportPackage::class,
        PassportPackage::class,
    ],
    // ...
];

public function addRoutes(Container $c, Router $router): Router
{
    $passportControl = $c->get(PassportControl::class);
    $middleware = new PassportControlMiddleware($passportControl);

    // routes here
}

$router->map('GET', '/lock-me', [MyController::class, 'someAction'])->middlewares([
    $c->get(SessionAuth::class), 
    $middleware->withOptions('admin')
]);

$router->map('GET', '/books/edit/{id:number}', [MyController::class, 'someAction'])->middlewares([
    $c->get(SessionAuth::class), 
    $middleware->withOptions('book-admin', 'id')
]);