Call DocuOCR from PHP with a few cURL or Guzzle calls: POST a PDF or image, start extraction, and read structured JSON back with named fields, tables and confidence scores. No OCR engine to host, no cloud SDK to wire.
The same endpoint reads digital and scanned PDFs, so one code path handles both, in plain PHP or a Laravel Http call. Copy the code below and run it against your own document. Last updated July 2026.
Upload a document to extract
Drop files here or click to upload
Up to 50 files
Uploading...
See the JSON your PHP would receive, right in the browser.
To use an OCR API in PHP, you send a document to an HTTPS endpoint and read the recognized data back as JSON, through cURL that ships with PHP or Guzzle that most projects already have. There is no OCR engine to install, no model to train, and with a REST API like DocuOCR no SDK to add. You authenticate with a Bearer API key, POST the file to get a file_id, start an extraction job, then poll or receive a webhook for the result. Because the response is JSON, json_decode turns it into a PHP array of named fields, table rows and confidence scores you can drop straight into a database, an Eloquent model or an accounting workflow. The same three calls work for a native PDF, a scanned PDF or a photo, so your code does not branch on how the document was made.
Three Guzzle calls, from a file on disk to a structured PHP array. Swap in your API key from the dashboard and point it at any PDF or image. Plain cURL works the same way if you would rather not add a dependency.
<?php
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://docuocr.com/api/documents/']);
$headers = ['Authorization' => 'Bearer ' . 'YOUR_API_KEY'];
// 1. Upload the PDF or image, get a file_id
$up = $client->post('upload', [
'headers' => $headers,
'multipart' => [['name' => 'file', 'contents' => fopen('invoice.pdf', 'r')]],
]);
$fileId = json_decode($up->getBody(), true)['file_id'];
// 2. Start extraction, get a job hash
$job = $client->post('extract', [
'headers' => $headers,
'json' => ['file_id' => $fileId],
]);
$hash = json_decode($job->getBody(), true)['extraction_hash'];
// 3. Poll until the JSON is ready
do {
sleep(2);
$res = json_decode($client->get("extraction/{$hash}", ['headers' => $headers])->getBody(), true);
} while ($res['status'] !== 'completed');
// $res['fields'] and $res['tables'] are ready to use
foreach ($res['fields'] as $field) {
echo $field['name'], ' = ', $field['value'], PHP_EOL;
}
That is the whole integration. In Laravel the same flow is three Http::withToken()->post() calls in a controller or a queued job. For a production batch, wrap each call in a try or catch block, add exponential backoff on HTTP 429, and register a webhook instead of the polling loop so results arrive as each document finishes. The document OCR API reference covers the full request and response shape.
PHP SDK coverage is thinner than Python or Node. AWS and Google ship maintained Composer packages; Azure and Mistral do not, so those are REST-only from PHP. Package status verified July 2026.
| OCR API | PHP package | What it returns | Best for |
|---|---|---|---|
| DocuOCR | cURL or Guzzle (plain REST, no SDK) | Named fields, tables and confidence as JSON | Fields plus tables from one call, scans included |
| AWS Textract | aws/aws-sdk-php (official) | Text, forms and tables as blocks | AWS-stack PHP teams already on the SDK |
| Google Cloud Vision | google/cloud-vision (official) | Text and bounding boxes, no named fields | Raw text OCR on the Google stack |
| Google Document AI | google/cloud-document-ai (official) | Text plus entities, needs a service account | Google-native document pipelines |
| Azure AI Document Intelligence | None (SDK retired 2021) - REST only | Text, layout and prebuilt-model fields | Azure-stack teams willing to call REST |
| Mistral Document AI | None official - REST only | Markdown plus structured output | LLM-based parsing of mixed content |
| Tesseract | thiagoalessio/tesseract_ocr (local binary) | Plain text only | Offline, low-volume, no API cost |
Two things matter in PHP. First, because Azure and Mistral give you no PHP SDK, you write REST calls for them anyway, so a REST-native API removes the inconsistency of mixing an SDK for one vendor with hand-rolled HTTP for another. Second, raw OCR APIs like Google Cloud Vision return text and coordinates, so you write the field mapping in PHP yourself; a document extraction API returns named fields and table rows already. See the full OCR API pricing comparison for what each costs per 1,000 pages.
Generate a key in the dashboard and send it as a Bearer token in the Authorization header.
POST a PDF, PNG, JPG, TIFF or WEBP to the upload endpoint and read the file_id from the JSON.
POST the file_id to start an async job and get an extraction_hash back.
Poll or receive a webhook, then json_decode gives you fields, tables and confidence.
A queued job posts each upload, reads the JSON, and writes fields to the database with Eloquent, no manual entry.
A PHP worker pulls invoices from an inbox or bucket, extracts totals and line items, and posts them to QuickBooks or an ERP.
A back-office tool turns scanned statements and reports into rows and columns, then exports them to Excel or a database.
A PHP SaaS adds a document upload feature that returns clean structured data for its customers with no engine to maintain.
A WooCommerce or WordPress plugin reads supplier documents and receipts and files the data without staff typing it in.
A verification flow reads IDs and forms, checks confidence scores, and routes low-confidence values to a human reviewer.
The full endpoint reference and response shape.
The same three calls from Python with requests.
The same three calls from Node.js with fetch.
Call the API from Java with the built-in HttpClient.
Pull tables from PDFs to Excel, CSV or JSON.
Per-1,000-page rates across the market.
Generate an API key, paste the three cURL or Guzzle calls above, and read structured JSON back in minutes. No engine to host, no SDK to learn, and a free tier to test the integration before you pay per page.