1. Go to this page and download the library: Download vicent/laque-identity 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/ */
vicent / laque-identity example snippets
use Laque\Identity\Core\IdentityService;
use Laque\Identity\Providers\MockProvider;
use Laque\Identity\Dto\IdentityQuery;
// Build a service with a provider (Mock here; swap with NidaProvider)
$service = new IdentityService(new MockProvider());
// Query using MRZ (passport TD3) or NIDA number/DoB
$q = new IdentityQuery(
nidaNumber: '19876543210987654321',
dateOfBirth: '1990-01-01',
firstName: 'FROLIAN',
lastName: 'ERNEZ',
phone: '0712 345 678',
tin: '123-456-789',
mrz: null // or provide two-line MRZ string
);
$result = $service->verify($q);
// $result->matched(): bool
// $result->score(): float // 0..1
// $result->reasons(): array
use Laque\Identity\Core\MrzParser;
$td3 = "P<TZAERNEZ<<FROLIAN<<<<<<<<<<<<<<<<<<\nC1234567<8TZA9001012M2601012<<<<<<<<<<";
$parsed = MrzParser::parse($td3);
// $parsed->documentNumber, $parsed->dateOfBirth, $parsed->expiryDate, etc.
use Laque\Identity\Providers\NidaProvider;
use Laque\Identity\Adapters\Psr18\HttpTransport;
use Laque\Identity\Core\IdentityService;
$transport = new HttpTransport(
baseUrl: getenv('NIDA_BASE_URL') ?: 'https://nida.example.tz/api/v1', // REPLACE
apiKey: getenv('NIDA_API_KEY') ?: 'replace-me'
);
$service = new IdentityService(new NidaProvider($transport));
// In your AppServiceProvider or a dedicated ServiceProvider
$this->app->singleton(Laque\Identity\Core\IdentityService::class, function($app) {
$cfg = config('laque_identity.nida');
$transport = new Laque\Identity\Adapters\Psr18\HttpTransport($cfg['base_url'], $cfg['api_key']);
return new Laque\Identity\Core\IdentityService(
new Laque\Identity\Providers\NidaProvider($transport),
$app->make(Psr\Log\LoggerInterface::class) // optional
);
});