How to generate barcodes in PHP using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to generate barcodes in PHP using Cloud API (low level)

This sample code will show how to generate barcodes in PHP using ByteScout Cloud API (low level).

It is also possible to read barcodes using Cloud API and PHP.

POST/GET endpoint:

https://bytescout.io/v1/barcode/generate

Code Sample:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: api_key
Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Bytescout\Client\API\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$api_instance = new Swagger\Client\Api\DefaultApi();
$name = name_example; // String | Filename for the generated image.
$type = type_example; // String | Barcode type. Valid values: Code128, Code39, Postnet, UPCA, EAN8, ISBN, Codabar, I2of5, Code93, EAN13, JAN13, Bookland, UPCE, PDF417, PDF417Truncated, DataMatrix, QRCode, Aztec, Planet, EAN128, GS1_128, USPSSackLabel, USPSTrayLabel, DeutschePostIdentcode, DeutschePostLeitcode, Numly, PZN, OpticalProduct, SwissPostParcel, RoyalMail, DutchKix, SingaporePostalCode, EAN2, EAN5, EAN14, MacroPDF417, MicroPDF417, GS1_DataMatrix, Telepen, IntelligentMail, GS1_DataBar_Omnidirectional, GS1_DataBar_Truncated, GS1_DataBar_Stacked, GS1_DataBar_Stacked_Omnidirectional, GS1_DataBar_Limited, GS1_DataBar_Expanded, GS1_DataBar_Expanded_Stacked, MaxiCode, Plessey, MSI, ITF14, GTIN12, GTIN8, GTIN13, GTIN14.
$value = value_example; // String | Barcode value.

try {
    $result = $api_instance->barcodeGeneratePost($name, $type, $value);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->barcodeGeneratePost: ', $e->getMessage(), PHP_EOL;
}
?>

prev
next