Read saved QR images
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() to read decoded QR text, raw payloads and the quality score.
Packagist
proc_open
Uses qrscan
MIT
Call the native qrscan binary from PHP 8.2+ without compiling PHP extensions and read typed report helpers.
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() to read decoded QR text, raw payloads and the quality score.
Executes qrscan through proc_open with an argument array and no shell, keeping uploaded filenames safe and PHP memory clean.
Call found(), detections(), texts(), score() and isComplete(), and persist $report->json verbatim to keep empty JSON objects intact.
Install the Composer package alongside 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 via Homebrew, Debian/RPM, Cargo, Scoop, AUR, AppImage, GitHub Releases or a container image.
The PHP package ships without an embedded decoder and never downloads qrscan on its own. Shared hosts 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') if qrscan is outside the web server’s PATH.
Keep the Composer package and the installed qrscan binary on the same release line so the startup version check passes.
Create a Scanner instance, call scan() with an image file path (PNG, JPEG, WebP or GIF) and Profile::Full, 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.
Store $report->json when saving or forwarding reports, because 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'] holds "https://qrcode-ai.com/". Use $report->texts(), $report->rawPayloads() and $report->score() for routine reads.
When no code is found, $report->found() is false and no exception is thrown. Catch QrcodeAi\BarcodeScanner\Exception\ScannerException (BinaryNotFound, UnsupportedVersion, ScanFailed with engineCode, ScanTimedOut or ProcessUnavailable).
Safe subprocess execution. Each scan() call launches qrscan with an argument array and no shell, so uploaded filenames with spaces, quotes or leading dashes are never interpreted. Write in-memory uploads to a temporary file before scanning.
Hosting and workload fit. Requires PHP 8.2+ with proc_open enabled and uses a 60-second default process timeout (ScanTimedOut). Spawning one process per scan fits web requests and queue workers better than tight loops across thousands of files.
Raw JSON and MIT licence. Save $report->json verbatim and treat decoded URLs as untrusted text. Adapter source carries the MIT licence; review the PHP adapter README and PHP package 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 report unchanged.
Your server needs PHP 8.2 or later with proc_open enabled, plus a compatible qrscan binary installed on the host or inside your container image. On shared hosts that disable proc_open, the package throws ProcessUnavailable.
No. The Composer package is written in pure PHP and keeps the Rust decoding engine outside the PHP process by calling qrscan directly.
$report->json holds the exact JSON string output by the engine. Since PHP associative arrays cannot distinguish an empty JSON object from an empty list, saving $report->json avoids lossy round-trips.
If no code is detected, $report->found() is false and nothing is thrown (verify that $report->isComplete() is true). Failures throw subclasses of ScannerException: BinaryNotFound, UnsupportedVersion, ScanFailed (with engineCode), ScanTimedOut or ProcessUnavailable.
Yes. qrscan runs via an argument array with no shell, so filenames containing spaces, quotes, leading dashes or shell characters are never interpreted. Always validate upload paths and treat decoded URLs as untrusted text.
No. Decoding runs locally through the installed qrscan binary with zero network calls, no QR Code AI account, no API key and no creation credits.
Yes. Current releases of the PHP adapter and qrscan engine carry the MIT licence for commercial and proprietary apps, provided copyright and licence notices are retained (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.