PHP QR Code Scanner SDK

Add offline QR code scanning to your PHP 8.2+ web app, Laravel backend or queue worker without compiling a PHP C extension. Install the MIT-licensed Composer adapter alongside the qrscan binary to get the unchanged JSON report and typed PHP helpers.

Text
use QrcodeAi\BarcodeScanner\Profile;
use QrcodeAi\BarcodeScanner\Scanner;

$scanner = new Scanner();
$report = $scanner->scan('label.png', Profile::Frame);
$qr = array_values(array_filter($report->detections(), fn($d) => $d['symbology'] === 'qr_code'))[0] ?? null;

echo $qr['content']['text'] ?? '';

Inspect the decoded resulthttps://qrcode-ai.com/

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.

composer require qrcode-ai-com/qrcode-barcode-scanner

Need to scan a code right now? Open the online reader

PHP QR Code Scanner SDK at a glance

  • Composer package, PHP 8.2+

    Packagist

  • No compiled PHP extension needed

    proc_open

  • Runs separately installed CLI

    Uses qrscan

  • Open-source licence

    MIT

Add offline QR scanning to PHP

Invoke the native qrscan binary from PHP 8.2+ without compiling PHP extensions and inspect typed report helpers.

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.

Out-of-process qrscan binary

Invokes qrscan through proc_open using an argument array with no shell so uploaded filenames remain safe and PHP memory stays clean.

Read array helpers or raw JSON

Call found(), detections(), texts(), score(), isComplete() and store $report->json verbatim to keep empty JSON objects intact.

Add QR image reading in PHP

Install the Composer package along with the qrscan CLI, then decode an image file with typed report helpers.

Install with Composer and add qrscan

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.

Decode a QR image file in PHP

Instantiate Scanner, pass an image file path (PNG, JPEG, WebP or GIF) with Profile::Full to scan(), and keep qr_code detections.

Text
<?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 [].

Inspect the decoded result

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).

Subprocess safety, hosting requirements and exceptions

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.

PHP QR Code Scanner documentation and licence

Official package documentation, ScanReport specification and licensing references.

PHP QR Code Scanner SDK questions

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.