Read saved QR images
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() and extract decoded QR text, raw payloads and quality score.
Packagist
proc_open
Uses qrscan
MIT
Invoke the native qrscan binary from PHP 8.2+ without compiling PHP extensions and inspect typed report helpers.
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() and extract decoded QR text, raw payloads and quality score.
Invokes qrscan through proc_open using an argument array with no shell so uploaded filenames remain safe and PHP memory stays clean.
Call found(), detections(), texts(), score(), isComplete() and store $report->json verbatim to keep empty JSON objects intact.
Install the Composer package along with the qrscan CLI, then decode an image file with typed report helpers.
Requires PHP 8.2 or later with proc_open enabled and qrcode-ai-com/qrcode-barcode-scanner on Packagist. Install the matching QR Code Scanner CLI binary separately using Homebrew, Debian/RPM, Cargo, Scoop, AUR, AppImage, GitHub Releases or a container image.
The PHP package carries no embedded decoder and never downloads qrscan on its own. Shared hosting servers that disable proc_open throw ProcessUnavailable.
composer require qrcode-ai-com/qrcode-barcode-scanner
Pass an explicit binary path via new Scanner('/path/to/qrscan') whenever qrscan is not in the web server’s PATH.
Keep the Composer package and the installed qrscan binary on the same release line so the startup version check succeeds.
Instantiate Scanner, pass an image file path (PNG, JPEG, WebP or GIF) with Profile::Full to scan(), and keep qr_code detections.
<?php
use QrcodeAi\BarcodeScanner\Profile;
use QrcodeAi\BarcodeScanner\Scanner;
$scanner = new Scanner();
$report = $scanner->scan('label.png', Profile::Full);
if ($report->isComplete()) {
foreach ($report->detections() as $detection) {
if ($detection['symbology'] === 'qr_code') {
echo $detection['content']['text'], "\n";
}
}
}
Profiles: Profile::Frame (decode only, null score), Profile::Fast (lighter scoring) and Profile::Full (default). Pass 0 as the third argument for an unbounded scan.
Persist $report->json when saving or forwarding reports: PHP arrays cannot tell an empty JSON object {} apart from an empty list [].
For a QR image encoding https://qrcode-ai.com/, $detection['content']['text'] returns "https://qrcode-ai.com/". Use $report->texts(), $report->rawPayloads() and $report->score() for routine reads.
When no code is found, $report->found() is false without throwing. Catch QrcodeAi\BarcodeScanner\Exception\ScannerException (BinaryNotFound, UnsupportedVersion, ScanFailed with engineCode, ScanTimedOut or ProcessUnavailable).
Safe subprocess execution. Each scan() call launches qrscan using an argument array and no shell, so uploaded filenames with spaces, quotes or leading hyphens are never interpreted. Write in-memory uploads to a temporary file before scanning.
Hosting and workload fit. Needs PHP 8.2+ with proc_open enabled and uses a default 60-second process timeout (ScanTimedOut). One process per scan works well for web requests and background queue workers rather than tight loops across thousands of images.
Raw JSON and MIT licence. Save $report->json verbatim and treat decoded URLs as untrusted text. 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, PHP 8.2, proc_open, qrscan binary, exceptions and licensing.
It is QR Code AI’s open-source MIT-licensed Composer package (qrcode-ai-com/qrcode-barcode-scanner on Packagist) that invokes a separately installed qrscan binary from PHP 8.2+ and returns its JSON scan report unchanged.
You need PHP 8.2 or later with proc_open enabled and a matching qrscan binary installed on your server or inside your container image. Some shared hosts disable proc_open, causing the package to throw ProcessUnavailable.
No. The Composer package is written in pure PHP and keeps the Rust decoding engine outside the PHP process by invoking qrscan directly.
$report->json holds the exact JSON string output by the engine. Because PHP associative arrays cannot distinguish an empty JSON object from an empty list, persisting $report->json prevents lossy round-trips.
If no code is found, $report->found() is false and no exception is thrown (check that $report->isComplete() is true). Runtime failures throw subclasses of ScannerException: BinaryNotFound, UnsupportedVersion, ScanFailed (with engineCode), ScanTimedOut or ProcessUnavailable.
Yes. qrscan is launched through an argument array with no shell, so filenames containing spaces, quotes, leading hyphens or shell characters are never interpreted. Always validate upload paths and treat decoded URLs as untrusted text.
No. All decoding happens locally through the installed qrscan binary 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 projects 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.