PHP code example of deaniliev / laravel-docling

1. Go to this page and download the library: Download deaniliev/laravel-docling library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

deaniliev / laravel-docling example snippets


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();

$result = Docling::convertFromFile(
    storage_path('app/documents/report.pdf'),
    ConvertOptions::make()->toFormats(['md', 'json'])
);

echo $result->markdown();
$json = $result->json();

$result = Docling::convertFromBase64(
    base64_encode(file_get_contents($path)),
    'report.pdf',
    ConvertOptions::make()->toFormats(['md'])
);

$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();

$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::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']);

$status = Docling::health();

use Deaniliev\Docling\Docling;

$client = Docling::make(
    baseUrl: 'http://localhost:5001',
    apiKey: 'secret',
);

$result = $client->convertFromUrl('https://example.com/doc.pdf');
bash
php artisan vendor:publish --tag=docling-config