PHP code example of minvws / puzi-php

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

    

minvws / puzi-php example snippets



// Request from your framework/controller
$uzi = new \MinVWS\PUZI\UziReader();
$user = $uzi->getDataFromRequest($request);
print $user->getUziNumber();

// In case of no request (deprecated):
$uzi = new \MinVWS\PUZI\UziReader();
$user = $uzi->getData();

print $user->getUziNumber();
var_dump($user->toArray());

$allowedTypes = [
    UziConstants::UZI_TYPE_CARE_PROVIDER,
    UziConstants::UZI_TYPE_NAMED_EMPLOYEE,
];
$allowedRoles = [
    UziConstants::UZI_ROLE_DOCTOR,    
    UziConstants::UZI_ROLE_PHARMACIST,    
];

$validator = new UziValidator(new UziReader(), true, $allowedTypes, $allowedRoles);
if ($validator->isValid($request)) {
    print "Validated as doctor or pharmasist";
}