PHP code example of habibalkhabbaz / identity-documents

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

    

habibalkhabbaz / identity-documents example snippets


return [
    "type" => "service_account",
    "project_id" => "",
    "private_key_id" => "",
    "private_key" => "",
    "client_email" => "",
    "client_id" => "",
    "auth_uri" => "",
    "token_uri" => "",
    "auth_provider_x509_cert_url" => "",
    "client_x509_cert_url" => "",
];

use Illuminate\Http\Request;
use HabibAlkhabbaz\IdentityDocuments\IdentityDocument;

class ExampleController {
	public function id(Request $request){
		$document = new IdentityDocument($request->front, $request->back);
	}
}

$mrz = $document->getMrz();

$parsed = $document->getParsedMrz();

$viz = $document->getViz();

$face = $document->getFace()

use Illuminate\Http\Request;
use HabibAlkhabbaz\IdentityDocuments\IdentityDocument;

class ExampleController {
	public function id(Request $request){
		$response = IdentityDocument::all($request->front, $request->back);
		return response()->json($response);
	}
}

[
	'type' => 'string', // TD1, TD2, TD3, MRVA, MRVB
	'mrz' => 'string', // Full MRZ
	'parsed' => [], // Array containing parsed MRZ
	'viz' => [], // Array containing parsed VIZ
	'face' => 'string', // Base64 image string
]

use Illuminate\Http\Request;
use HabibAlkhabbaz\IdentityDocuments\IdentityDocument;

class ExampleController {
	public function id(Request $request){
		$document = new IdentityDocument($request->front, $request->back);
		$document->mergeBackAndFrontImages();
		$mrz = $document->getMrz();
	}
}

	'merge_images' => false, // bool

use Illuminate\Http\Request;
use App\Services\TesseractService;
use HabibAlkhabbaz\IdentityDocuments\IdentityDocument;

class ExampleController {
	public function id(Request $request){
		$document = new IdentityDocument($request->front, $request->back);
		$document->setOcrService(TesseractService::class);
		$mrz = $document->getMrz();
	}
}

use Illuminate\Http\Request;
use App\Services\AmazonFdService;
use HabibAlkhabbaz\IdentityDocuments\IdentityDocument;

class ExampleController {
	public function id(Request $request){
		$document = new IdentityDocument($request->front, $request->back);
		$document->setFaceDetectionService(AmazonFdService::class);
		$mrz = $document->getFace();
	}
}
 bash
$ php artisan vendor:publish --provider="HabibAlkhabbaz\IdentityDocuments\IdentityDocumentsServiceProvider"