Read saved QR images
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() and read decoded QR text, raw payloads and quality score.
Packagist
proc_open
Uses qrscan
MIT
Drive the native qrscan binary from PHP 8.2+ without compiled PHP extensions and inspect typed report helpers.
Pass a PNG, JPEG, WebP or GIF file path to $scanner->scan() and read decoded QR text, raw payloads and quality score.
Runs qrscan via proc_open with an argument array and no shell, keeping uploaded filenames safe and PHP memory clean.
Use found(), detections(), texts(), score(), isComplete() and store $report->json verbatim to preserve empty JSON objects.
Install the Composer package and the qrscan CLI, then decode an image file using 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 contains no embedded decoder and never downloads qrscan automatically. 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') when qrscan is not on the web server’s PATH.
Keep the Composer package and installed qrscan binary on the same release line to pass the startup version check.
Instantiate Scanner, 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 (reduced scoring) and Profile::Full (default). Pass a third argument of 0 for an unbounded scan.
Keep $report->json when saving or forwarding reports: PHP arrays cannot distinguish an empty JSON object {} from an empty list [].
For a QR image encoding https://qrcode-ai.com/, $detection['content']['text'] is "https://qrcode-ai.com/". Use $report->texts(), $report->rawPayloads() and $report->score() for common reads.
No code found sets $report->found() to false without throwing. Catch QrcodeAi\BarcodeScanner\Exception\ScannerException (BinaryNotFound, UnsupportedVersion, ScanFailed with engineCode, ScanTimedOut or ProcessUnavailable).
Safe subprocess execution. Each scan() invokes qrscan from an argument array with no shell, so uploaded filenames containing spaces, quotes or leading hyphens are never interpreted. Write in-memory uploads to a temporary file first.
Hosting and workload fit. Requires PHP 8.2+ with proc_open enabled and defaults to a 60-second process timeout (ScanTimedOut). One process per scan suits web requests and queue workers rather than tight loops over thousands of images.
Raw JSON and MIT licence. Store $report->json verbatim and treat decoded URLs as untrusted text. Adapter source is MIT-licensed; see 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 drives a separately installed qrscan binary from PHP 8.2+ and returns its JSON report unchanged.
You need PHP 8.2 or later with proc_open enabled and a compatible qrscan binary installed on the host or inside your container image. Some shared hosts disable proc_open, in which case the package throws ProcessUnavailable.
No. The Composer package is pure PHP and keeps the Rust decoding engine outside the PHP process by invoking qrscan directly.
$report->json contains the exact JSON string printed by the engine. PHP associative arrays cannot distinguish an empty JSON object from an empty list, so saving $report->json avoids lossy round-trips.
When no code is found, $report->found() is false and no exception is thrown (confirm $report->isComplete() is true). Runtime failures throw subclasses of ScannerException: BinaryNotFound, UnsupportedVersion, ScanFailed (with engineCode), ScanTimedOut or ProcessUnavailable.
Yes. qrscan is invoked via an argument list with no shell, so filenames containing spaces, quotes, leading hyphens or shell metacharacters are never interpreted. Always validate upload paths and treat decoded URLs as untrusted text.
No. Decoding runs locally through the installed qrscan binary with no network calls, 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 applications while retaining copyright and licence notices (see LICENSING.md). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.