The source code sample below shows how to read barcodes in PHP using ByteScout Cloud API (low level).

Also, check this article to find out how to generate barcodes in PHP using Cloud API.

Sample.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Barcode Reader Cloud API Example</title>
</head>

<body>

    <form name="form1" enctype="multipart/form-data" method="post" action="read_barcode.php">
        <p>
            <label>Copy-paste your API Key for Bytescout.IO here</label>
            <input type="text" name="apiKey" placeholder="API Key"/>
        </p>
        <p>
            <label>Input File</label>
            <input type="hidden" name="MAX_FILE_SIZE" value="8000000"/>
            <input type="file" name="file"/>
        </p>
        <p>
            <label>Barcode types to find</label>
            <select multiple="multiple" size="10" name="barcodeTypesToFind[]">
                <option selected="selected">All</option>
                <option>All1D</option>
                <option>All2D</option>
                <option>AllOMRElements</option>
                <option>AustralianPostCode</option>
                <option>Aztec</option>
                <option>CircularI2of5</option>
                <option>Codabar</option>
                <option>CodablockF</option>
                <option>Code128</option>
                <option>Code16K</option>
                <option>Code39</option>
                <option>Code39Extended</option>
                <option>Code39Mod43</option>
                <option>Code39Mod43Extended</option>
                <option>Code93</option>
                <option>DataMatrix</option>
                <option>EAN13</option>
                <option>EAN2</option>
                <option>EAN5</option>
                <option>EAN8</option>
                <option>GS1</option>
                <option>GS1DataBarExpanded</option>
                <option>GS1DataBarExpandedStacked</option>
                <option>GS1DataBarLimited</option>
                <option>GS1DataBarOmnidirectional</option>
                <option>GS1DataBarStacked</option>
                <option>GTIN12</option>
                <option>GTIN13</option>
                <option>GTIN14</option>
                <option>GTIN8</option>
                <option>IntelligentMail</option>
                <option>Interleaved2of5</option>
                <option>ITF14</option>
                <option>MaxiCode</option>
                <option>MICR</option>
                <option>MicroPDF</option>
                <option>MSI</option>
                <option>PatchCode</option>
                <option>PDF417</option>
                <option>Pharmacode</option>
                <option>PostNet</option>
                <option>PZN</option>
                <option>QRCode</option>
                <option>RoyalMail</option>
                <option>RoyalMailKIX</option>
                <option>Trioptic</option>
                <option>UPCA</option>
                <option>UPCE</option>
                <option>UPU</option>
                <option>Checkbox</option>
                <option>Circle</option>
                <option>Oval</option>
                <option>UnderlinedField</option>
                <option>HorizontalLine</option>
                <option>VerticalLine</option>
                <option>Segment</option>
            </select>
        </p>

        <input type="submit" name="submit" value="Proceed" />
    </form>

</body>
</html>

read_barcode.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Barcode Reader Results</title>
</head>
<body>

<?php 

// Get submitted form data
$apiKey = $_POST["apiKey"];
$barcodeTypesToFind = $_POST["barcodeTypesToFind"];


// 1. UPLOAD FILE

// Create File API URL
$url = "https://bytescout.io/api/v1/file/upload?apiKey=" . $apiKey; // Get your API key at http://www.bytescout.io/

// Create request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
    "file" => "@" . $_FILES["file"]["tmp_name"] . ";filename=" . $_FILES["file"]["name"]
    ));
// Execute request
$result = curl_exec($curl);

if (curl_errno($curl))
{
    // Display request error
    echo "Error: " . curl_error($curl);
}
else // Display request results
{
    $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($status_code == 200)
    {
        // 2. READ BARCODES FROM UPLOADED FILE
        readBarcode($apiKey, $barcodeTypesToFind, $result);
    }
    else
    {
        // Display service reported error
        echo "<p>Status code: " . $status_code . "</p>"; 
        echo "<p>" . $result . "</p>"; 
    }
}

// Cleanup
curl_close($curl);


function readBarcode($apiKey, $barcodeTypesToFind, $uploadedFileId) 
{
    // Create Barcode Reader API URL
    $url = "https://bytescout.io/api/v1/barcodereader/read?apiKey=" . $apiKey;
    
    // Create Barcode Reader options
    $options = array(
        "properties" => array(
            "startPageIndex" => 0,
            "endPageIndex" => 0,
            "barcodeTypesToFind" => array(),
            "pdfRenderingResolution" => 300
            ),
        "inputType" => "fileId",
        "input" => $uploadedFileId,
        "outputType" => "content"
        );
    // Fill selected barcode types
    foreach ($barcodeTypesToFind as &$barcodeType)
         $options["properties"]["barcodeTypesToFind"][$barcodeType] = true;

    // Create request
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($options));
    // Execute request
    $result = curl_exec($curl);
    
    if (curl_errno($curl))
    {
        // Display request error
        echo "Error: " . curl_error($curl);
    }
    else // Display request results
    {
        $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if ($status_code == 200)
        {
            // Display decoding results
            echo "<div><h2>Decoding Results:</h2><pre>" . $result . "</pre></div>";
        }
        else
        {
            // Display service reported errors
            echo "<p>Status code: " . $status_code . "</p>"; 
            echo "<p>" . $result . "</p>"; 
        }
    }
    
    // Cleanup
    curl_close($curl);
}

?>

</body>
</html>