deaniliev / laravel-docling
Laravel package for the Docling Serve document conversion API
v1.0.0
2026-07-31 09:27 UTC
Requires
- php: ^8.2
- illuminate/http: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
Laravel package for the Docling Serve document conversion API.
Convert PDFs, Office docs, HTML, images, and more to Markdown, JSON, HTML, or text from your Laravel app.
Requirements
- PHP 8.2+
- Laravel 11 or 12
- A running Docling Serve instance
Installation
composer require deaniliev/laravel-docling
Publish the config (optional):
php artisan vendor:publish --tag=docling-config
Configuration
Add these to your .env:
DOCLING_BASE_URL=http://localhost:5001 DOCLING_API_KEY= DOCLING_TIMEOUT=120 DOCLING_POLL_INTERVAL=2 DOCLING_POLL_TIMEOUT=600
| Env | Description | Default |
|---|---|---|
DOCLING_BASE_URL |
Docling Serve base URL | http://localhost:5001 |
DOCLING_API_KEY |
Sent as X-Api-Key when set |
null |
DOCLING_TIMEOUT |
HTTP timeout (seconds) | 120 |
DOCLING_POLL_INTERVAL |
Async poll interval (seconds) | 2 |
DOCLING_POLL_TIMEOUT |
Max wait for async tasks (seconds) | 600 |
Usage
Docling Serve v1 expects a sources array (with kind: http|file). This package builds that payload for you.
Convert from URL
use Deaniliev\Docling\Facades\Docling; use Deaniliev\Docling\ConvertOptions; $result = Docling::convertFromUrl( 'https://arxiv.org/pdf/2501.17887', ConvertOptions::make()->toFormats(['md'])->doOcr(true) ); echo $result->markdown();
Convert from local file
$result = Docling::convertFromFile( storage_path('app/documents/report.pdf'), ConvertOptions::make()->toFormats(['md', 'json']) ); echo $result->markdown(); $json = $result->json();
Convert from base64
$result = Docling::convertFromBase64( base64_encode(file_get_contents($path)), 'report.pdf', ConvertOptions::make()->toFormats(['md']) );
Asynchronous conversion
$task = Docling::convertFromUrlAsync('https://example.com/large.pdf'); // Poll until finished (throws on failure or timeout) $task = Docling::waitForTask($task->taskId); $result = Docling::result($task->taskId); echo $result->markdown();
Or manage polling yourself:
$task = Docling::convertFromFileAsync('/path/to/doc.pdf'); while (! $task->isFinished()) { sleep(2); $task = Docling::poll($task->taskId); } if ($task->isSuccess()) { $result = Docling::result($task->taskId); }
Options
ConvertOptions covers common Docling options and accepts any extra fields via with():
$options = ConvertOptions::make() ->fromFormats(['pdf']) ->toFormats(['md', 'json']) ->imageExportMode('embedded') ->doOcr(true) ->ocrLang(['en']) ->tableMode('accurate') ->pdfBackend('docling_parse') ->pipeline('standard') ->pageRange([1, 5]) ->doPictureDescription(true) ->with(['vlm_pipeline_preset' => 'default']);
Health check
$status = Docling::health();
Without the Facade
use Deaniliev\Docling\Docling; $client = Docling::make( baseUrl: 'http://localhost:5001', apiKey: 'secret', ); $result = $client->convertFromUrl('https://example.com/doc.pdf');
Testing
composer install
composer test
License
MIT