How to Create a QR Code in PHP

Cloudmersive
1 min readMar 14, 2023

--

Looking for a quick, free & easy-to-use QR code API to include in your applications? You’re in luck: the below API rapidly generates QR codes from text input, returning the encoding for a new PNG file. To get up and running, just grab a free-tier API key from our website and use the ready-to-run PHP code examples provided below to structure your API call.

To install the SDK, run this command:

composer require cloudmersive/cloudmersive_barcode_api_client

After that, use the code examples below to make your request:

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

// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');



$apiInstance = new Swagger\Client\Api\GenerateBarcodeApi(


new GuzzleHttp\Client(),
$config
);
$value = "value_example"; // string | QR code text to convert into the QR code barcode

try {
$result = $apiInstance->generateBarcodeQRCode($value);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling GenerateBarcodeApi->generateBarcodeQRCode: ', $e->getMessage(), PHP_EOL;
}
?>

Now you can create QR code PNGs with a single request. Easy!

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.