Read label images
Pass a PNG, JPEG, WebP or GIF label path to $scanner->scan(). A Code 128 label encoding STOCK-4827 returns that exact string.
Packagist
proc_open
1D + 2D
MIT
Decode 1D and 2D barcode image files in PHP 8.2+ web apps and queue workers without compiling PHP extensions.
Pass a PNG, JPEG, WebP or GIF label path to $scanner->scan(). A Code 128 label encoding STOCK-4827 returns that exact string.
Runs qrscan via proc_open with an argument list and no shell so uploaded label filenames stay safe.
Read each detection’s symbology and content text as PHP strings so UPC and EAN leading zeros stay intact for database lookups.
Install the Composer package along with the qrscan CLI, then read barcode identifiers and symbologies safely.
Requires PHP 8.2 or later with proc_open enabled and qrcode-ai-com/qrcode-barcode-scanner on Packagist. Install the matching Barcode Scanner CLI binary separately using Homebrew, Debian/RPM, Cargo, Scoop, AUR, AppImage, GitHub Releases or a container image.
The Composer package bundles no embedded decoder and never downloads qrscan at runtime. Hosts that disable proc_open throw ProcessUnavailable.
composer require qrcode-ai-com/qrcode-barcode-scanner
Pass an explicit path to new Scanner('/path/to/qrscan') whenever qrscan sits outside the web server’s PATH.
Keep the Composer adapter and the installed qrscan binary on a matching release line.
Call $scanner->scan() with a PNG, JPEG, WebP or GIF file path and filter detections down to the barcode symbologies your app handles.
To test with a known sample, create a Code 128 barcode with Barcode Generator encoding STOCK-4827 and scan the exported PNG.
<?php
use QrcodeAi\BarcodeScanner\Profile;
use QrcodeAi\BarcodeScanner\Scanner;
$qrTypes = ['qr_code', 'micro_qr_code', 'rectangular_micro_qr_code'];
$scanner = new Scanner();
$report = $scanner->scan('label.png', Profile::Frame);
if ($report->isComplete()) {
foreach ($report->detections() as $detection) {
if (!in_array($detection['symbology'], $qrTypes, true)) {
echo $detection['symbology'], ': ', $detection['content']['text'], "\n";
}
}
}
Choose Profile::Full (or pass 0 as the third budget argument) for worn or low-contrast label photos.
Store $report->json verbatim when saving reports; PHP arrays cannot tell empty JSON objects {} apart from empty lists [].
For a Code 128 label encoding STOCK-4827, $detection['symbology'] is "code128" and $detection['content']['text'] is "STOCK-4827". A UPC-A code such as 012345678905 retains its leading zero as a PHP string.
No matching barcode leaves $report->found() false without throwing. Catch ScannerException subclasses (BinaryNotFound, UnsupportedVersion, ScanFailed with engineCode, ScanTimedOut or ProcessUnavailable).
Sixteen barcode formats. Returns the installed qrscan engine’s results for EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode (ISBN maps to ean13, GS1-128 to code128, ITF-14 to itf).
Process model and strings. Launches qrscan through proc_open without a shell (safe for arbitrary filenames; 60-second default timeout) and fits web requests or background queue jobs. Keep identifiers as strings so leading zeros survive, and look up products in your own database.
Raw JSON and MIT licence. Save $report->json rather than re-encoding $report->data. The adapter source is MIT-licensed; see the PHP adapter README and PHP package GitHub repository.
Official package documentation, ScanReport specification and licensing references.
Composer, formats, leading zeros, proc_open, qrscan binary and licensing.
It is QR Code AI’s open-source MIT-licensed Composer package (qrcode-ai-com/qrcode-barcode-scanner on Packagist) that runs a separately installed qrscan binary from PHP 8.2+ and returns decoded 1D and 2D barcode strings unchanged.
It decodes all 16 barcode formats supported by the installed qrscan engine (EAN-13, EAN-8, UPC-A, UPC-E, Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar, GS1 DataBar Expanded, Data Matrix, PDF417, Aztec and MaxiCode) plus QR Code, Micro QR and rMQR.
PHP 8.2 or later with proc_open enabled and a compatible qrscan binary installed on your host or inside your container. Shared hosts that disable proc_open raise ProcessUnavailable.
No. It returns each barcode identifier as a PHP string together with its symbology (and parsed GS1 fields where present), keeping UPC-A and EAN-13 leading zeros intact. Query your own product catalogue or ERP database separately.
$report->json contains the exact JSON string output by qrscan. Because PHP arrays cannot distinguish empty JSON objects from empty lists, persisting $report->json keeps the report structure exact.
A blank image sets $report->found() to false without throwing (verify $report->isComplete() is true). Failures throw subclasses of ScannerException: BinaryNotFound, UnsupportedVersion, ScanFailed (with engineCode), ScanTimedOut (60s default) or ProcessUnavailable.
Yes. Both the PHP adapter and qrscan run 100% locally offline with zero network requests, no QR Code AI account, no API key and no creation credits.
Yes. Current releases of the PHP adapter and qrscan engine are MIT-licensed for commercial and proprietary PHP apps as long as you keep the copyright and licence notices (see LICENSING.md). SDK use is independent of QR Code AI’s paid creation plans and seven-day Premium trial.