dessop / ocr
DESSOP OCR API PHP SDK
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.8
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Official PHP SDK for the DESSOP OCR API.
Package: dessop/ocr
API: https://ocr.dessop.com
Requirements
- PHP 8.2+
- Composer 2+
Installation
composer require dessop/ocr
Configuration
use Dessop\Ocr\OcrClient; $ocr = new OcrClient( 'https://ocr.dessop.com', getenv('DESSOP_OCR_API_KEY'), 300, );
Process a document
$result = $ocr->process('/path/to/document.pdf'); if ($result->successful()) { echo $result->text(); }
The synchronous request uses POST /ocr.
Process asynchronously
$job = $ocr->processAsync('/path/to/document.pdf'); echo $job->jobId(); echo $job->status(); // pending, processing, completed or failed
submit() is an alias for processAsync().
Query a job and retry a failed job:
$job = $ocr->getJob($jobId); if ($job->status() === 'completed') { echo $job->text(); } $ocr->retryJob($jobId);
job() is an alias for getJob().
Available methods:
$result->jobId(); $result->filename(); $result->pages(); $result->text(); $result->client(); $result->data(); $result->get('some.nested.value'); $result->status(); $result->documentId();
Documents and files
$documents = $ocr->documents(); $document = $ocr->document($documentId); $text = $ocr->documentText($documentId); $originalFile = $ocr->documentFile($documentId); $ocrPdf = $ocr->documentOcrPdf($documentId);
The file methods return the downloaded binary content from DESSOP OCR.
Health check
if ($ocr->health()) { echo 'DESSOP OCR is available.'; }
This calls GET /health.
Exceptions
OcrAuthenticationExceptionOcrValidationExceptionOcrTimeoutExceptionOcrServerExceptionOcrException
HTTP 401 and 403 responses throw OcrAuthenticationException; validation errors (422), timeouts (408/504 or connection timeout), rate limits (429), server errors (500+) and invalid JSON are mapped to the SDK exceptions above.
Security
Never hardcode the API key. Store it in an environment variable or secret manager. Never log the key or send it to frontend code.
License
MIT. Copyright (c) 2026 DESSOP.