Skip to main content
Setting up a streamlined local development environment is crucial for building and testing this system efficiently. Let’s get this documented.

The Core Question: docling CLI vs. API

You’ve hit on a key architectural point. While having docling as a CLI is great for one-off tests, for an application integration, you absolutely want a containerized API version. Why you need the API version:
  1. Decoupling: Your Laravel application should not depend on a specific executable being in a specific path on the host machine. It should communicate with a service over a network protocol (HTTP). This makes your app portable and mirrors a production setup.
  2. Process Management: Calling a CLI from a PHP queue worker (shell_exec or Process) is complex to manage. You have to handle stdout/stderr, process timeouts, and potential hangs. An HTTP API is far more robust and predictable.
  3. Concurrency: A dedicated API service can handle multiple concurrent requests from your queue workers far more gracefully than spawning multiple CLI processes.
  4. State & Caching: The API version can maintain state or caches (like loaded models) in memory, making subsequent calls much faster. The CLI has to bootstrap from scratch every single time.
Conclusion: We will proceed with the setup assuming docling runs as a containerized HTTP service.

Minimal Development Environment Topology

On a single machine, your services will run in their own processes/containers but communicate over localhost. This diagram shows the logical flow.

Setting Up The Development Environment

Here is a step-by-step guide to integrate the new AI components into your existing setup.

Prerequisites

  • Your existing Laravel DMS, MongoDB, and Minio are running.
  • Neo4j is running and accessible (we’ll assume on localhost).
  • Docker and Docker Compose are installed on your machine.

Step 1: Run docling as an API Service

We will use Docker Compose to define and run the docling service. This is clean and easily manageable.
  1. Create a docker-compose.yml file in the root of your Laravel project (or a dedicated folder).
  2. Add the docling service definition to this file. The official docling documentation should specify the image name. We’ll use a placeholder ghcr.io/docling-ai/docling:latest.
  1. Start the service: Open your terminal in the same directory as the docker-compose.yml file and run:
  1. Verify it’s running: You can check the logs with docker-compose logs -f docling. After a minute, test the API endpoint (the exact path may vary, check docling docs). A simple health-check endpoint is common.

Step 2: Configure Your Laravel Application

Now, we need to tell Laravel how to connect to all these new services.
  1. Install Required PHP Libraries:
  1. Update Your .env file: Add the connection details for the new services.
  1. (Optional but Recommended) Create a Config File: To keep things clean, create a config file for your services.
config/services.php

Step 3: Set Up and Run the Laravel Queue Worker

The worker is the background process that will do all the heavy lifting.
  1. Open a new terminal window and navigate to your Laravel project root.
  2. Run the queue worker: This command starts a worker that will listen for jobs on the queue you configured in .env.
Keep this terminal window open. You will see output here when jobs are processed.

Step 4: Implement the Core Logic (Artisan Commands & Jobs)

Now you can start building the pieces that connect everything.
  1. Create the Main Job: This job will orchestrate the call to docling and then write to Neo4j.
app/Jobs/ProcessDocumentForGraph.php
  1. Create the Artisan Command for Backfilling:
app/Console/Commands/ProcessArchiveForGraph.php
With this setup, your development workflow is:
  1. Run docker-compose up -d once to start docling.
  2. Start your Laravel dev server (php artisan serve).
  3. Start your queue worker in another terminal (php artisan queue:work).
  4. Run php artisan docs:process-archive to kick off the ingestion process.
  5. Watch the queue worker terminal for job processing logs.
  6. Query Neo4j Browser (http://localhost:7474) to see your graph being built.