Download the PHP package rakibdevs/mrz-parser without Composer
On this page you can find all versions of the php package rakibdevs/mrz-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rakibdevs/mrz-parser
More information about rakibdevs/mrz-parser
Files in rakibdevs/mrz-parser
Package mrz-parser
Short Description A PHP package for MRZ (Machine Readable Zones) code parser for Passport, Visa & Travel Documents.
License MIT
Homepage https://github.com/rakibdevs/mrz-parser
Informations about the package mrz-parser
MRZ (Machine Readable Zones) Parser for PHP
A PHP package for MRZ (Machine Readable Zones) code parser for Passport, Visa & Travel Document (TD1 & TD2).
It reads the machine-readable zone, extracts the document fields, and — new in v2 — verifies the ICAO 9303 check digits so you can tell whether the data is internally consistent.
Requirements
- PHP 8.2 or higher
Installation
You can install the package via composer:
Usage
Output
Check-digit validation
Every result carries a valid flag (overall) and a validation map with the outcome of each ICAO 9303 check digit (card_no, date_of_birth, date_of_expiry, personal_number for passports, and the composite). Visas carry no composite check digit, so their validation map omits it. Use these to reject OCR mistakes or tampered documents.
Input handling
Input is normalized before parsing: \r\n / \r line endings are converted to \n, surrounding whitespace is trimmed, and blank lines are dropped — so MRZ strings copied from Windows or OCR output parse the same as clean input. Dates are validated strictly (impossible dates such as Feb 30 return null), and a date of birth that would resolve to the future is shifted back a century.
Advanced usage
Typed result object
read() returns an MrzResult value object with typed properties and helpers, while toArray() gives you the same array as parse():
Non-throwing parsing
parse()/read() throw on unrecognised input. Use the try* variants to get null instead:
Strict check-digit mode
Pass strict: true to reject documents whose check digits don't verify (throws InvalidChecksumException; the try* variants return null):
Name transliteration
The MRZ name field only holds A–Z. Convert a visual-zone (accented) name to its MRZ form, or compare the two:
Laravel
The package ships an auto-discovered service provider and a validation rule (requires illuminate/support):
Supported Document
Passport (TD3)
Visa
Or
Travel Document (TD1)
Travel Document (TD2)
French National ID (legacy 2×36 Carte Nationale d'Identité)
This pre-2021 format predates ICAO TD1/TD2 and has its own layout (no expiry date is encoded).
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Md. Rakibul Islam
- All Contributors
Special thanks to tetrahydra for organised country list, Al Amin for help extracting information.
License
The MIT License (MIT). Please see License File for more information.