The Best PHP API for Global License Plate OCR (Free Image Testing)

Deploy automated license plate recognition (ALPR) built for global scale. Upload a vehicle image for a free test today and extract native scripts and multi-plate layouts seamlessly using PHP.

The Problem with Global ALPR Parsers in PHP

Enterprise PHP applications, especially those built on frameworks like Laravel or Symfony, often struggle with legacy ALPR libraries that are optimized only for standard Latin alphabets. These traditional tools fail when encountering complex layouts from the Middle East or Asia, and struggle to accurately extract native scripts (Arabic, Cyrillic, Thai, Chinese). Furthermore, generic models often lack the ability to process multi-plate setups, like tractor-trailer configurations, or identify secondary data such as plate colors and vehicle types.

The StructOCR Solution

StructOCR allows your PHP backend to offload complex vehicle image processing to our specialized deep learning models. Our API transcends generic models by accurately extracting native scripts worldwide exactly as printed. By returning validated JSON directly to your PHP application, you can easily integrate multi-dimensional attributes—including plate numbers, vehicle types, and country inferences—into your global logistics and tolling workflows. Explore our flexible pricing to scale your production environment seamlessly.

Common Use Cases

  • Toll Collection & Parking: Automate entry and exit gates globally by capturing primary plate numbers and vehicle classifications instantly.
  • Global Logistics & Border Control: Track multi-plate configurations (e.g., stacked trailer and prime mover plates) simultaneously across international borders.
  • Law Enforcement: Cross-reference vehicle types and plate colors to detect unregistered or commercial vehicles dynamically.
Need more testing? Create a free account to get 200 free credits (equals 200 License Plate scans).

Implementation: Raw API Request

Complete, runnable PHP code to encode a vehicle image in Base64 and extract license plate data via cURL. For other language examples and deep parameter explanations, visit the full License Plate OCR API Reference.

Prerequisite: PHP 7.4+ or PHP 8+ with the cURL extension enabled

PHP EXAMPLE
<?php

// Get 200 free credits:
// 👉 https://structocr.com/register

$apiKey = "YOUR_API_KEY"; // Replace with your actual API key
$imagePath = "path/to/your/vehicle_image.jpg"; // Replace with the path to your image

// 1. Read image and encode to Base64
$imageData = file_get_contents($imagePath);
if ($imageData === false) {
    die("Error: Unable to read image file.\n");
}
$base64Img = base64_encode($imageData);

// 2. Create JSON payload
$payload = json_encode(['img' => $base64Img]);

// 3. Build the HTTP request via cURL (Requires application/json)
$ch = curl_init("https://api.structocr.com/v1/license-plate");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "x-api-key: " . $apiKey,
    "Content-Type: application/json",
    "Content-Length: " . strlen($payload)
]);

echo "Uploading Base64 image to StructOCR API...\n";

// 4. Send the request and receive the response
$response = curl_exec($ch);

if (curl_errno($ch)) {
    die("cURL Error: " . curl_error($ch) . "\n");
}
curl_close($ch);

// 5. Parse the JSON response
$jsonResponse = json_decode($response, true);

// 6. Extract the License Plate data
if (isset($jsonResponse['success']) && $jsonResponse['success'] === true) {
    $data = $jsonResponse['data'];
    echo "✅ Extraction Successful!\n";
    echo "Plates Detected: " . count($data['plates']) . "\n";
    
    $countryGuess = isset($data['country_guess']) && $data['country_guess'] !== null ? $data['country_guess'] : "N/A";
    echo "Country Guess: " . $countryGuess . "\n";
    echo "Confidence: " . $data['confidence'] . "\n";
    
    echo "\n--- Raw Data ---\n";
    echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n";
} else {
    $errorCode = $jsonResponse['code'] ?? "Unknown Code";
    $errorMsg = $jsonResponse['message'] ?? "Unknown Error";
    echo "❌ Error [{$errorCode}]: {$errorMsg}\n";
}

Technical Specs

  • •Input format: application/json payload with Base64 encoded string
  • •File Constraints: Max 4.5MB (decoded), compress to < 300KB for best speed
  • •Supported Formats: Standard Data URI schemas, raw Base64 strings (JPG, PNG, WebP)
  • •Language Support: Global scripts (Arabic, Chinese, Thai, Cyrillic, etc.)
  • •Output: JSON (Multi-dimensional attributes)

Key Features

  • •Global Coverage: Optimized for worldwide plates spanning the Middle East, Asia, Europe, and the Americas.
  • •Native Script Retention: Extracts local scripts exactly as printed without translation or transliteration.
  • •Multi-Plate Parsing: Natively handles extracting multiple plates from a single vehicle (e.g., stacked trailer plates).

Sample JSON Response

The API returns a clean JSON array with details on all detected plates, preserving native characters and strict enums.

{
  "success": true,
  "data": {
    "plates": [
      {
        "plate_number": "TRE 1631M",
        "plate_color": "yellow",
        "plate_type": "trailer"
      },
      {
        "plate_number": "XB 98X",
        "plate_color": "yellow",
        "plate_type": "commercial"
      }
    ],
    "region_text": null,
    "country_guess": "Singapore",
    "confidence": "High"
  }
}

Frequently Asked Questions

How should I encode the image?

Send the image as a Base64 encoded string wrapped in a JSON payload. The Base64 string must not contain any internal whitespaces or newlines.

What is the maximum file size?

The maximum decoded payload restriction is 4.5MB. Exceeding this will trigger a 413 FILE_TOO_LARGE error.

Can it read non-English characters?

Yes. Our engine natively retains and extracts local scripts like Arabic, Thai, and Cyrillic exactly as printed.

You May Also Like

Related tutorials, platform guides, and comparisons

Tutorial

C# License Plate OCR API

C# License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

C# · License Plate
Tutorial

Python License Plate OCR API

Python License Plate OCR SDK tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Python · License Plate
Tutorial

Java License Plate OCR API

Java License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Java · License Plate
Tutorial

Node.js License Plate OCR API

Node.js License Plate OCR SDK tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Node.js · License Plate
Tutorial

Go License Plate OCR API

Golang License Plate OCR tutorial. Upload an image for a free test! Accurately extract global license plates, native scripts, colors, and vehicle types.

Go · License Plate
Tutorial

PHP Shipping Container OCR API

Tutorial: Learn how to use the StructOCR PHP Client via cURL for shipping container OCR. Upload an image for a free test! Extract ISO 6346 container numbers and check them against the ISO check digit. Includes code samples and JSON schemas.

PHP · Container
Country Tutorial

Germany Personalausweis OCR Python SDK

Python Tutorial: Automate KYC in Germany. Extract data from Personalausweis and validate TD1 MRZ using StructOCR Python SDK. Supports native German text.

Python · personalausweis
Country Tutorial

Ghana Ghana Card OCR Python SDK

Python Tutorial: Automate KYC in Ghana. Extract data, Personal ID Number, and validate TD1 MRZ from Ghana Card using StructOCR Python SDK.

Python · ghana card
Country Tutorial

Greece Deltio Taftotitas OCR Python SDK

Python Tutorial: Automate KYC in Greece. Extract dual-script data from Deltio Taftotitas and validate TD1 MRZ using StructOCR Python SDK.

Python · deltio taftotitas
Country Tutorial

Hungary Személyazonosító OCR Python SDK

Python Tutorial: Automate KYC in Hungary. Extract data from Személyazonosító and validate TD1 MRZ using StructOCR Python SDK. Supports native Hungarian text and accents.

Python · személyazonosító

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

From tutorial to production in 5 minutes.

You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.

Instant Access Cancel Anytime No Credit Card